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 set_reproducible_seed(seed): | |
import torch | |
import numpy as np | |
import random | |
import os | |
torch.manual_seed(seed) | |
if torch.cuda.is_available(): | |
torch.cuda.manual_seed(seed) | |
torch.cuda.manual_seed_all(seed) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# model is a keras Model | |
weights = model.weights # weight tensors | |
gradients = model.optimizer.get_gradients(model.total_loss, weights) # gradient tensors | |
import keras.backend as K | |
input_tensors = [model.inputs[0], # input data | |
model.sample_weights[0], # sample weights | |
model.targets[0], # labels | |
K.learning_phase(), # train or test mode | |
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
d = io.load('yourfile.hdf5') | |
#ix = [random.sample(range(4), 4) for _ in xrange(d['X'].shape[0])] | |
ix = np.argsort(d['X'][:, :4])[:, ::-1] | |
def _pairwise(iterable): | |
'''s -> (s0, s1), (s2, s3), (s4, s5), ...''' | |
a = iter(iterable) | |
return izip(a, a) | |
cols = list(_pairwise(range(d['X'].shape[-1])[::4])) # or you can just type [(0, 4), (8, 12), (16, 20), (24, 28)] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 bash | |
# ** TO USE ROOT, type load_root after all of this has been installed ** | |
# GENERAL SETUP | |
################ | |
# env usefulness | |
PYTHON_VERSION="2.7.10" | |
PY_PAYLOAD="Python-${PYTHON_VERSION}.tgz" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder