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 adam(loss, all_params, learning_rate=0.001, b1=0.9, b2=0.999, e=1e-8, | |
gamma=1-1e-8): | |
""" | |
ADAM update rules | |
Default values are taken from [Kingma2014] | |
References: | |
[Kingma2014] Kingma, Diederik, and Jimmy Ba. | |
"Adam: A Method for Stochastic Optimization." | |
arXiv preprint arXiv:1412.6980 (2014). |
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 tensorflow as tf | |
data_arr = [ | |
{ | |
"img": np.random.randn(10, 30) | |
}, | |
{ | |
"img": np.random.randn(10, 30) | |
} | |
] |
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
# Skriv records fil med et sample og forsoeg at loade det igen med tf.data | |
import numpy as np | |
import tensorflow as tf | |
## WRITE SINGLE EXAMPLE | |
label = 1 | |
FILEPATH = "TEST_RECORDS" |
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 | |
class ConfusionMatrix: | |
""" | |
Simple confusion matrix class | |
row is the true class, column is the predicted class | |
""" | |
def __init__(self, n_classes, class_names=None): | |
self.n_classes = n_classes | |
if class_names is None: | |
self.class_names = map(str, range(n_classes)) |
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
(pytorch_build) sorson@hyperion:~$ git clone https://github.com/pytorch/pytorch.git | |
Cloning into 'pytorch'... | |
remote: Counting objects: 24898, done. | |
remote: Compressing objects: 100% (38/38), done. | |
remote: Total 24898 (delta 8), reused 0 (delta 0), pack-reused 24860 | |
Receiving objects: 100% (24898/24898), 15.81 MiB | 7.68 MiB/s, done. | |
Resolving deltas: 100% (18207/18207), done. | |
Checking connectivity... done. | |
(pytorch_build) sorson@hyperion:~$ cd pytorch | |
(pytorch_build) sorson@hyperion:~/pytorch$ export CUDA_HOME=/usr/local/cuda |
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
--[[ A Confusion Matrix class | |
Example: | |
conf = optim.ConfusionMatrix( {'cat','dog','person'} ) -- new matrix | |
conf:zero() -- reset matrix | |
for i = 1,N do | |
conf:add( neuralnet:forward(sample), label ) -- accumulate errors | |
end | |
print(conf) -- print matrix |
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 | |
import theano | |
import theano.tensor as T | |
import lasagne.nonlinearities as nonlinearities | |
import lasagne.init as init | |
from lasagne.utils import unroll_scan | |
from lasagne.layers import * | |
import lasagne.layers.helper as helper |
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 adam(loss, all_params, learning_rate=0.0002, beta1=0.1, beta2=0.001, | |
epsilon=1e-8, gamma=1-1e-7): | |
""" | |
ADAM update rules | |
Default values are taken from [Kingma2014] | |
References: | |
[Kingma2014] Kingma, Diederik, and Jimmy Ba. | |
"Adam: A Method for Stochastic Optimization." | |
arXiv preprint arXiv:1412.6980 (2014). |
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 | |
import theano | |
import theano.tensor as T | |
from theano import ifelse | |
from .. import init | |
from .. import nonlinearities | |
from .base import Layer | |
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
from __future__ import print_function | |
import gzip | |
import itertools | |
import pickle | |
import os | |
import sys | |
PY2 = sys.version_info[0] == 2 |
NewerOlder