In this article, I will share some of my experience on installing NVIDIA driver and CUDA on Linux OS. Here I mainly use Ubuntu as example. Comments for CentOS/Fedora are also provided as much as I can.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _to_one_hot(y, num_classes): | |
scatter_dim = len(y.size()) | |
y_tensor = y.view(*y.size(), -1) | |
zeros = torch.zeros(*y.size(), num_classes, dtype=y.dtype) | |
return zeros.scatter(scatter_dim, y_tensor, 1) | |
print(_to_one_hot(torch.as_tensor([2, 4, 7]), num_classes=10)) | |
print(_to_one_hot(torch.as_tensor([[1, 5 ,6], [2, 4, 7]]), num_classes=10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from keras.models import Model | |
from keras.layers import Dense, Activation, Lambda, Input | |
import keras.backend as K | |
from keras.utils import to_categorical | |
# Model definition | |
def foo(ip): | |
a = ip[1] | |
x = ip[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_one_hot(labels, C=2): | |
''' | |
Converts an integer label torch.autograd.Variable to a one-hot Variable. | |
Parameters | |
---------- | |
labels : torch.autograd.Variable of torch.cuda.LongTensor | |
N x 1 x H x W, where N is batch size. | |
Each value is an integer representing correct classification. | |
C : integer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git remote rm origin | |
$ git remote add origin git@github.com:aplikacjainfo/proj1.git | |
$ git config master.remote origin | |
$ git config master.merge refs/heads/master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Copyright 2016 Massachusetts Institute of Technology | |
"""Extract images from a rosbag. | |
""" | |
import os | |
import argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Deep Auto-Encoder implementation | |
An auto-encoder works as follows: | |
Data of dimension k is reduced to a lower dimension j using a matrix multiplication: | |
softmax(W*x + b) = x' | |
where W is matrix from R^k --> R^j | |
A reconstruction matrix W' maps back from R^j --> R^k |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy | |
from pandas import DataFrame | |
from sklearn.feature_extraction.text import CountVectorizer | |
from sklearn.naive_bayes import MultinomialNB | |
from sklearn.pipeline import Pipeline | |
from sklearn.cross_validation import KFold | |
from sklearn.metrics import confusion_matrix, f1_score | |
NEWLINE = '\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Install Postgres 9.1, PostGIS 2.0 and pgRouting on a clean Ubuntu 12.04 install (64 bit) | |
# updated to PostGIS 2.0.1 | |
# basics | |
apt-get install python-software-properties | |
apt-add-repository ppa:sharpie/for-science # To get GEOS 3.3.3 | |
# install the following pacakages |