partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
optimize_updates
General optimization function for Theano. Parameters: params - parameters gradients - gradients config - training config Returns: Theano updates :type config: deepy.TrainerConfig or dict
deepy/trainers/optimize.py
def optimize_updates(params, gradients, config=None, shapes=None): """ General optimization function for Theano. Parameters: params - parameters gradients - gradients config - training config Returns: Theano updates :type config: deepy.TrainerConfig or dict """ ...
def optimize_updates(params, gradients, config=None, shapes=None): """ General optimization function for Theano. Parameters: params - parameters gradients - gradients config - training config Returns: Theano updates :type config: deepy.TrainerConfig or dict """ ...
[ "General", "optimization", "function", "for", "Theano", ".", "Parameters", ":", "params", "-", "parameters", "gradients", "-", "gradients", "config", "-", "training", "config", "Returns", ":", "Theano", "updates", ":", "type", "config", ":", "deepy", ".", "Tra...
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/optimize.py#L19-L123
[ "def", "optimize_updates", "(", "params", ",", "gradients", ",", "config", "=", "None", ",", "shapes", "=", "None", ")", ":", "if", "config", "and", "isinstance", "(", "config", ",", "dict", ")", ":", "config", "=", "TrainerConfig", "(", "config", ")", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
optimize_function
Create a optimizing function receives gradients. Parameters: params - parameters config - training configuration Returns: updating function receives gradients
deepy/trainers/optimize.py
def optimize_function(params, config=None): """ Create a optimizing function receives gradients. Parameters: params - parameters config - training configuration Returns: updating function receives gradients """ gs = [dim_to_var(p.ndim) for p in params] updates, _ = op...
def optimize_function(params, config=None): """ Create a optimizing function receives gradients. Parameters: params - parameters config - training configuration Returns: updating function receives gradients """ gs = [dim_to_var(p.ndim) for p in params] updates, _ = op...
[ "Create", "a", "optimizing", "function", "receives", "gradients", ".", "Parameters", ":", "params", "-", "parameters", "config", "-", "training", "configuration", "Returns", ":", "updating", "function", "receives", "gradients" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/optimize.py#L125-L136
[ "def", "optimize_function", "(", "params", ",", "config", "=", "None", ")", ":", "gs", "=", "[", "dim_to_var", "(", "p", ".", "ndim", ")", "for", "p", "in", "params", "]", "updates", ",", "_", "=", "optimize_updates", "(", "params", ",", "gs", ",", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GeneralNeuralTrainer._learning_updates
Return updates in the training.
deepy/trainers/trainers.py
def _learning_updates(self): """ Return updates in the training. """ params = self.training_params() gradients = self.get_gradients(params) return self.optimization_updates(params, gradients)
def _learning_updates(self): """ Return updates in the training. """ params = self.training_params() gradients = self.get_gradients(params) return self.optimization_updates(params, gradients)
[ "Return", "updates", "in", "the", "training", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/trainers.py#L40-L46
[ "def", "_learning_updates", "(", "self", ")", ":", "params", "=", "self", ".", "training_params", "(", ")", "gradients", "=", "self", ".", "get_gradients", "(", "params", ")", "return", "self", ".", "optimization_updates", "(", "params", ",", "gradients", ")...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GeneralNeuralTrainer.training_params
Get parameters to be optimized.
deepy/trainers/trainers.py
def training_params(self): """ Get parameters to be optimized. """ params = self.network.parameters # Freeze parameters if self.config.fixed_parameters: logging.info("fixed parameters: %s" % ", ".join(map(str, self.config.fixed_parameters))) params...
def training_params(self): """ Get parameters to be optimized. """ params = self.network.parameters # Freeze parameters if self.config.fixed_parameters: logging.info("fixed parameters: %s" % ", ".join(map(str, self.config.fixed_parameters))) params...
[ "Get", "parameters", "to", "be", "optimized", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/trainers.py#L48-L57
[ "def", "training_params", "(", "self", ")", ":", "params", "=", "self", ".", "network", ".", "parameters", "# Freeze parameters", "if", "self", ".", "config", ".", "fixed_parameters", ":", "logging", ".", "info", "(", "\"fixed parameters: %s\"", "%", "\", \"", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GeneralNeuralTrainer.optimization_updates
Return updates from optimization.
deepy/trainers/trainers.py
def optimization_updates(self, params, gradients): """ Return updates from optimization. """ updates, free_parameters = optimize_updates(params, gradients, self.config) self.network.free_parameters.extend(free_parameters) logging.info("Added %d free parameters for optimiz...
def optimization_updates(self, params, gradients): """ Return updates from optimization. """ updates, free_parameters = optimize_updates(params, gradients, self.config) self.network.free_parameters.extend(free_parameters) logging.info("Added %d free parameters for optimiz...
[ "Return", "updates", "from", "optimization", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/trainers.py#L65-L72
[ "def", "optimization_updates", "(", "self", ",", "params", ",", "gradients", ")", ":", "updates", ",", "free_parameters", "=", "optimize_updates", "(", "params", ",", "gradients", ",", "self", ".", "config", ")", "self", ".", "network", ".", "free_parameters",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GeneralNeuralTrainer.learning_function
Get the learning function. :param func: :return:
deepy/trainers/trainers.py
def learning_function(self): """ Get the learning function. :param func: :return: """ network_updates = list(self.network.updates) + list(self.network.training_updates) learning_updates = list(self._learning_updates()) update_list = network_updates + learn...
def learning_function(self): """ Get the learning function. :param func: :return: """ network_updates = list(self.network.updates) + list(self.network.training_updates) learning_updates = list(self._learning_updates()) update_list = network_updates + learn...
[ "Get", "the", "learning", "function", ".", ":", "param", "func", ":", ":", "return", ":" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/trainers.py#L74-L94
[ "def", "learning_function", "(", "self", ")", ":", "network_updates", "=", "list", "(", "self", ".", "network", ".", "updates", ")", "+", "list", "(", "self", ".", "network", ".", "training_updates", ")", "learning_updates", "=", "list", "(", "self", ".", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
AttentionLayer._glimpse_sensor
Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 4x12 matrix
examples/attention_models/baseline_model.py
def _glimpse_sensor(self, x_t, l_p): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 4x12 matrix """ # Turn l_p to the left-top point of rectangle l_p = l_p * 14 + 14 - 2 l_p = T.cast(T.round(l_p), "int32") ...
def _glimpse_sensor(self, x_t, l_p): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 4x12 matrix """ # Turn l_p to the left-top point of rectangle l_p = l_p * 14 + 14 - 2 l_p = T.cast(T.round(l_p), "int32") ...
[ "Parameters", ":", "x_t", "-", "28x28", "image", "l_p", "-", "2x1", "focus", "vector", "Returns", ":", "4x12", "matrix" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/baseline_model.py#L37-L62
[ "def", "_glimpse_sensor", "(", "self", ",", "x_t", ",", "l_p", ")", ":", "# Turn l_p to the left-top point of rectangle", "l_p", "=", "l_p", "*", "14", "+", "14", "-", "2", "l_p", "=", "T", ".", "cast", "(", "T", ".", "round", "(", "l_p", ")", ",", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
AttentionLayer._refined_glimpse_sensor
Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 7*14 matrix
examples/attention_models/baseline_model.py
def _refined_glimpse_sensor(self, x_t, l_p): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 7*14 matrix """ # Turn l_p to the left-top point of rectangle l_p = l_p * 14 + 14 - 4 l_p = T.cast(T.round(l_p), "int...
def _refined_glimpse_sensor(self, x_t, l_p): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 7*14 matrix """ # Turn l_p to the left-top point of rectangle l_p = l_p * 14 + 14 - 4 l_p = T.cast(T.round(l_p), "int...
[ "Parameters", ":", "x_t", "-", "28x28", "image", "l_p", "-", "2x1", "focus", "vector", "Returns", ":", "7", "*", "14", "matrix" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/baseline_model.py#L64-L81
[ "def", "_refined_glimpse_sensor", "(", "self", ",", "x_t", ",", "l_p", ")", ":", "# Turn l_p to the left-top point of rectangle", "l_p", "=", "l_p", "*", "14", "+", "14", "-", "4", "l_p", "=", "T", ".", "cast", "(", "T", ".", "round", "(", "l_p", ")", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
AttentionLayer._glimpse_network
Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 4x12 matrix
examples/attention_models/baseline_model.py
def _glimpse_network(self, x_t, l_p): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 4x12 matrix """ sensor_output = self._refined_glimpse_sensor(x_t, l_p) sensor_output = T.flatten(sensor_output) h_g = self._...
def _glimpse_network(self, x_t, l_p): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector Returns: 4x12 matrix """ sensor_output = self._refined_glimpse_sensor(x_t, l_p) sensor_output = T.flatten(sensor_output) h_g = self._...
[ "Parameters", ":", "x_t", "-", "28x28", "image", "l_p", "-", "2x1", "focus", "vector", "Returns", ":", "4x12", "matrix" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/baseline_model.py#L88-L101
[ "def", "_glimpse_network", "(", "self", ",", "x_t", ",", "l_p", ")", ":", "sensor_output", "=", "self", ".", "_refined_glimpse_sensor", "(", "x_t", ",", "l_p", ")", "sensor_output", "=", "T", ".", "flatten", "(", "sensor_output", ")", "h_g", "=", "self", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
AttentionLayer._action_network
Parameters: h_t - 256x1 vector Returns: 10x1 vector
examples/attention_models/baseline_model.py
def _action_network(self, h_t): """ Parameters: h_t - 256x1 vector Returns: 10x1 vector """ z = self._relu(T.dot(h_t, self.W_a) + self.B_a) return self._softmax(z)
def _action_network(self, h_t): """ Parameters: h_t - 256x1 vector Returns: 10x1 vector """ z = self._relu(T.dot(h_t, self.W_a) + self.B_a) return self._softmax(z)
[ "Parameters", ":", "h_t", "-", "256x1", "vector", "Returns", ":", "10x1", "vector" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/baseline_model.py#L112-L120
[ "def", "_action_network", "(", "self", ",", "h_t", ")", ":", "z", "=", "self", ".", "_relu", "(", "T", ".", "dot", "(", "h_t", ",", "self", ".", "W_a", ")", "+", "self", ".", "B_a", ")", "return", "self", ".", "_softmax", "(", "z", ")" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
get_network
Get baseline model. Parameters: model - model path Returns: network
examples/attention_models/first_glimpse_model.py
def get_network(model=None, std=0.005, disable_reinforce=False, random_glimpse=False): """ Get baseline model. Parameters: model - model path Returns: network """ network = NeuralClassifier(input_dim=28 * 28) network.stack_layer(FirstGlimpseLayer(std=std, disable_reinforce=di...
def get_network(model=None, std=0.005, disable_reinforce=False, random_glimpse=False): """ Get baseline model. Parameters: model - model path Returns: network """ network = NeuralClassifier(input_dim=28 * 28) network.stack_layer(FirstGlimpseLayer(std=std, disable_reinforce=di...
[ "Get", "baseline", "model", ".", "Parameters", ":", "model", "-", "model", "path", "Returns", ":", "network" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/first_glimpse_model.py#L192-L204
[ "def", "get_network", "(", "model", "=", "None", ",", "std", "=", "0.005", ",", "disable_reinforce", "=", "False", ",", "random_glimpse", "=", "False", ")", ":", "network", "=", "NeuralClassifier", "(", "input_dim", "=", "28", "*", "28", ")", "network", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
FirstGlimpseLayer._first_glimpse_sensor
Compute first glimpse position using down-sampled image.
examples/attention_models/first_glimpse_model.py
def _first_glimpse_sensor(self, x_t): """ Compute first glimpse position using down-sampled image. """ downsampled_img = theano.tensor.signal.downsample.max_pool_2d(x_t, (4,4)) downsampled_img = downsampled_img.flatten() first_l = T.dot(downsampled_img, self.W_f) ...
def _first_glimpse_sensor(self, x_t): """ Compute first glimpse position using down-sampled image. """ downsampled_img = theano.tensor.signal.downsample.max_pool_2d(x_t, (4,4)) downsampled_img = downsampled_img.flatten() first_l = T.dot(downsampled_img, self.W_f) ...
[ "Compute", "first", "glimpse", "position", "using", "down", "-", "sampled", "image", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/first_glimpse_model.py#L38-L54
[ "def", "_first_glimpse_sensor", "(", "self", ",", "x_t", ")", ":", "downsampled_img", "=", "theano", ".", "tensor", ".", "signal", ".", "downsample", ".", "max_pool_2d", "(", "x_t", ",", "(", "4", ",", "4", ")", ")", "downsampled_img", "=", "downsampled_im...
090fbad22a08a809b12951cd0d4984f5bd432698
test
FirstGlimpseLayer._core_network
Parameters: x_t - 28x28 image l_p - 2x1 focus vector h_p - 256x1 vector Returns: h_t, 256x1 vector
examples/attention_models/first_glimpse_model.py
def _core_network(self, l_p, h_p, x_t): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector h_p - 256x1 vector Returns: h_t, 256x1 vector """ g_t = self._glimpse_network(x_t, l_p) h_t = self._tanh(T.dot(g_t, self.W_h_g)...
def _core_network(self, l_p, h_p, x_t): """ Parameters: x_t - 28x28 image l_p - 2x1 focus vector h_p - 256x1 vector Returns: h_t, 256x1 vector """ g_t = self._glimpse_network(x_t, l_p) h_t = self._tanh(T.dot(g_t, self.W_h_g)...
[ "Parameters", ":", "x_t", "-", "28x28", "image", "l_p", "-", "2x1", "focus", "vector", "h_p", "-", "256x1", "vector", "Returns", ":", "h_t", "256x1", "vector" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/first_glimpse_model.py#L107-L133
[ "def", "_core_network", "(", "self", ",", "l_p", ",", "h_p", ",", "x_t", ")", ":", "g_t", "=", "self", ".", "_glimpse_network", "(", "x_t", ",", "l_p", ")", "h_t", "=", "self", ".", "_tanh", "(", "T", ".", "dot", "(", "g_t", ",", "self", ".", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
MyJointTrainingModel.prepare
All codes that create parameters should be put into 'setup' function.
examples/tutorials/tutorial2.py
def prepare(self): """ All codes that create parameters should be put into 'setup' function. """ self.output_dim = 10 self.encoder = Chain(self.input_dim).stack(Dense(self.internal_layer_size, 'tanh')) self.decoder = Chain(self.internal_layer_size).stack(Dense(self.input_...
def prepare(self): """ All codes that create parameters should be put into 'setup' function. """ self.output_dim = 10 self.encoder = Chain(self.input_dim).stack(Dense(self.internal_layer_size, 'tanh')) self.decoder = Chain(self.internal_layer_size).stack(Dense(self.input_...
[ "All", "codes", "that", "create", "parameters", "should", "be", "put", "into", "setup", "function", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/tutorials/tutorial2.py#L27-L41
[ "def", "prepare", "(", "self", ")", ":", "self", ".", "output_dim", "=", "10", "self", ".", "encoder", "=", "Chain", "(", "self", ".", "input_dim", ")", ".", "stack", "(", "Dense", "(", "self", ".", "internal_layer_size", ",", "'tanh'", ")", ")", "se...
090fbad22a08a809b12951cd0d4984f5bd432698
test
MyJointTrainingModel.compute_tensor
Build the computation graph here.
examples/tutorials/tutorial2.py
def compute_tensor(self, x): """ Build the computation graph here. """ internal_variable = self.encoder.compute_tensor(x) decoding_output = self.decoder.compute_tensor(internal_variable) classification_output = self.classifier.compute_tensor(internal_variable) ...
def compute_tensor(self, x): """ Build the computation graph here. """ internal_variable = self.encoder.compute_tensor(x) decoding_output = self.decoder.compute_tensor(internal_variable) classification_output = self.classifier.compute_tensor(internal_variable) ...
[ "Build", "the", "computation", "graph", "here", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/tutorials/tutorial2.py#L43-L65
[ "def", "compute_tensor", "(", "self", ",", "x", ")", ":", "internal_variable", "=", "self", ".", "encoder", ".", "compute_tensor", "(", "x", ")", "decoding_output", "=", "self", ".", "decoder", ".", "compute_tensor", "(", "internal_variable", ")", "classificat...
090fbad22a08a809b12951cd0d4984f5bd432698
test
BasicDataset.map
Process all data with given function. The scheme of function should be x,y -> x,y.
deepy/dataset/basic.py
def map(self, func): """ Process all data with given function. The scheme of function should be x,y -> x,y. """ if self._train_set: self._train_set = map(func, self._train_set) if self._valid_set: self._valid_set = map(func, self._valid_set) ...
def map(self, func): """ Process all data with given function. The scheme of function should be x,y -> x,y. """ if self._train_set: self._train_set = map(func, self._train_set) if self._valid_set: self._valid_set = map(func, self._valid_set) ...
[ "Process", "all", "data", "with", "given", "function", ".", "The", "scheme", "of", "function", "should", "be", "x", "y", "-", ">", "x", "y", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/basic.py#L30-L40
[ "def", "map", "(", "self", ",", "func", ")", ":", "if", "self", ".", "_train_set", ":", "self", ".", "_train_set", "=", "map", "(", "func", ",", "self", ".", "_train_set", ")", "if", "self", ".", "_valid_set", ":", "self", ".", "_valid_set", "=", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
BasicDataset.vectorize_target
Make targets be one-hot vectors.
deepy/dataset/basic.py
def vectorize_target(self, size): """ Make targets be one-hot vectors. """ if self._train_set: self._train_set = self._vectorize_set(self._train_set, size) if self._valid_set: self._valid_set = self._vectorize_set(self._valid_set, size) if self._te...
def vectorize_target(self, size): """ Make targets be one-hot vectors. """ if self._train_set: self._train_set = self._vectorize_set(self._train_set, size) if self._valid_set: self._valid_set = self._vectorize_set(self._valid_set, size) if self._te...
[ "Make", "targets", "be", "one", "-", "hot", "vectors", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/basic.py#L51-L60
[ "def", "vectorize_target", "(", "self", ",", "size", ")", ":", "if", "self", ".", "_train_set", ":", "self", ".", "_train_set", "=", "self", ".", "_vectorize_set", "(", "self", ".", "_train_set", ",", "size", ")", "if", "self", ".", "_valid_set", ":", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
BasicDataset.report
Print dataset statistics.
deepy/dataset/basic.py
def report(self): """ Print dataset statistics. """ logging.info("%s train=%d valid=%d test=%d" % (self.__class__.__name__, len(list(self._train_set)) if self._train_set else 0, ...
def report(self): """ Print dataset statistics. """ logging.info("%s train=%d valid=%d test=%d" % (self.__class__.__name__, len(list(self._train_set)) if self._train_set else 0, ...
[ "Print", "dataset", "statistics", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/basic.py#L62-L69
[ "def", "report", "(", "self", ")", ":", "logging", ".", "info", "(", "\"%s train=%d valid=%d test=%d\"", "%", "(", "self", ".", "__class__", ".", "__name__", ",", "len", "(", "list", "(", "self", ".", "_train_set", ")", ")", "if", "self", ".", "_train_se...
090fbad22a08a809b12951cd0d4984f5bd432698
test
CustomizeTrainer.train
We train over mini-batches and evaluate periodically.
deepy/trainers/customize_trainer.py
def train(self, train_set, valid_set=None, test_set=None, train_size=None): '''We train over mini-batches and evaluate periodically.''' iteration = 0 while True: if not iteration % self.config.test_frequency and test_set: try: self.test(iteration, ...
def train(self, train_set, valid_set=None, test_set=None, train_size=None): '''We train over mini-batches and evaluate periodically.''' iteration = 0 while True: if not iteration % self.config.test_frequency and test_set: try: self.test(iteration, ...
[ "We", "train", "over", "mini", "-", "batches", "and", "evaluate", "periodically", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/customize_trainer.py#L28-L66
[ "def", "train", "(", "self", ",", "train_set", ",", "valid_set", "=", "None", ",", "test_set", "=", "None", ",", "train_size", "=", "None", ")", ":", "iteration", "=", "0", "while", "True", ":", "if", "not", "iteration", "%", "self", ".", "config", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLM.sample
Sample outputs from LM.
examples/lm/lm.py
def sample(self, input, steps): """ Sample outputs from LM. """ inputs = [[onehot(self.input_dim, x) for x in input]] for _ in range(steps): target = self.compute(inputs)[0,-1].argmax() input.append(target) inputs[0].append(onehot(self.input_di...
def sample(self, input, steps): """ Sample outputs from LM. """ inputs = [[onehot(self.input_dim, x) for x in input]] for _ in range(steps): target = self.compute(inputs)[0,-1].argmax() input.append(target) inputs[0].append(onehot(self.input_di...
[ "Sample", "outputs", "from", "LM", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/lm/lm.py#L60-L69
[ "def", "sample", "(", "self", ",", "input", ",", "steps", ")", ":", "inputs", "=", "[", "[", "onehot", "(", "self", ".", "input_dim", ",", "x", ")", "for", "x", "in", "input", "]", "]", "for", "_", "in", "range", "(", "steps", ")", ":", "target...
090fbad22a08a809b12951cd0d4984f5bd432698
test
ClassOutputLayer.compute_tensor
:param x: (batch, time, vec)
examples/lm/layers.py
def compute_tensor(self, x): """ :param x: (batch, time, vec) """ # Target class class_matrix = self.target_tensor // self.output_size class_vector = class_matrix.reshape((-1,)) # Target index target_matrix = self.target_tensor % self.output_size t...
def compute_tensor(self, x): """ :param x: (batch, time, vec) """ # Target class class_matrix = self.target_tensor // self.output_size class_vector = class_matrix.reshape((-1,)) # Target index target_matrix = self.target_tensor % self.output_size t...
[ ":", "param", "x", ":", "(", "batch", "time", "vec", ")" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/lm/layers.py#L49-L75
[ "def", "compute_tensor", "(", "self", ",", "x", ")", ":", "# Target class", "class_matrix", "=", "self", ".", "target_tensor", "//", "self", ".", "output_size", "class_vector", "=", "class_matrix", ".", "reshape", "(", "(", "-", "1", ",", ")", ")", "# Targ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Attention.compute_alignments
Compute the alignment weights based on the previous state.
deepy/layers/attention.py
def compute_alignments(self, prev_state, precomputed_values, mask=None): """ Compute the alignment weights based on the previous state. """ WaSp = T.dot(prev_state, self.Wa) UaH = precomputed_values # For test time the UaH will be (time, output_dim) if UaH.ndim =...
def compute_alignments(self, prev_state, precomputed_values, mask=None): """ Compute the alignment weights based on the previous state. """ WaSp = T.dot(prev_state, self.Wa) UaH = precomputed_values # For test time the UaH will be (time, output_dim) if UaH.ndim =...
[ "Compute", "the", "alignment", "weights", "based", "on", "the", "previous", "state", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/attention.py#L29-L50
[ "def", "compute_alignments", "(", "self", ",", "prev_state", ",", "precomputed_values", ",", "mask", "=", "None", ")", ":", "WaSp", "=", "T", ".", "dot", "(", "prev_state", ",", "self", ".", "Wa", ")", "UaH", "=", "precomputed_values", "# For test time the U...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Attention.compute_context_vector
Compute the context vector with soft attention.
deepy/layers/attention.py
def compute_context_vector(self, prev_state, inputs, precomputed_values=None, mask=None): """ Compute the context vector with soft attention. """ precomputed_values = precomputed_values if precomputed_values else self.precompute(inputs) align_weights = self.compute_alignments(pre...
def compute_context_vector(self, prev_state, inputs, precomputed_values=None, mask=None): """ Compute the context vector with soft attention. """ precomputed_values = precomputed_values if precomputed_values else self.precompute(inputs) align_weights = self.compute_alignments(pre...
[ "Compute", "the", "context", "vector", "with", "soft", "attention", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/attention.py#L52-L59
[ "def", "compute_context_vector", "(", "self", ",", "prev_state", ",", "inputs", ",", "precomputed_values", "=", "None", ",", "mask", "=", "None", ")", ":", "precomputed_values", "=", "precomputed_values", "if", "precomputed_values", "else", "self", ".", "precomput...
090fbad22a08a809b12951cd0d4984f5bd432698
test
MultiGPUTrainer.train
Train the model in multi-GPU environment.
deepy/multigpu/worker.py
def train(self, train_set, valid_set=None, test_set=None, train_size=None): """ Train the model in multi-GPU environment. """ from platoon.channel import Worker from platoon.param_sync import EASGD, ASGD server_port = self._port param_map = self.create_param_map()...
def train(self, train_set, valid_set=None, test_set=None, train_size=None): """ Train the model in multi-GPU environment. """ from platoon.channel import Worker from platoon.param_sync import EASGD, ASGD server_port = self._port param_map = self.create_param_map()...
[ "Train", "the", "model", "in", "multi", "-", "GPU", "environment", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/multigpu/worker.py#L59-L159
[ "def", "train", "(", "self", ",", "train_set", ",", "valid_set", "=", "None", ",", "test_set", "=", "None", ",", "train_size", "=", "None", ")", ":", "from", "platoon", ".", "channel", "import", "Worker", "from", "platoon", ".", "param_sync", "import", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
concatenate
A utility function of concatenate.
deepy/tensor/functions.py
def concatenate(vars, axis=-1): """ A utility function of concatenate. """ from deepy.core.neural_var import NeuralVariable if isinstance(vars[0], NeuralVariable): concat_var = Concatenate(axis=axis).compute(*vars) if axis == -1 or axis == vars[0].tensor.ndim - 1: concat_...
def concatenate(vars, axis=-1): """ A utility function of concatenate. """ from deepy.core.neural_var import NeuralVariable if isinstance(vars[0], NeuralVariable): concat_var = Concatenate(axis=axis).compute(*vars) if axis == -1 or axis == vars[0].tensor.ndim - 1: concat_...
[ "A", "utility", "function", "of", "concatenate", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/tensor/functions.py#L38-L49
[ "def", "concatenate", "(", "vars", ",", "axis", "=", "-", "1", ")", ":", "from", "deepy", ".", "core", ".", "neural_var", "import", "NeuralVariable", "if", "isinstance", "(", "vars", "[", "0", "]", ",", "NeuralVariable", ")", ":", "concat_var", "=", "C...
090fbad22a08a809b12951cd0d4984f5bd432698
test
var
Wrap a Theano tensor into the variable for defining neural network. :param last_dim: last dimension of tensor, 0 indicates that the last dimension is flexible :rtype: deepy.core.neural_var.NeuralVariable
deepy/tensor/functions.py
def var(tensor_type, last_dim=0, test_shape=None): """ Wrap a Theano tensor into the variable for defining neural network. :param last_dim: last dimension of tensor, 0 indicates that the last dimension is flexible :rtype: deepy.core.neural_var.NeuralVariable """ # Create tensor from deepy.co...
def var(tensor_type, last_dim=0, test_shape=None): """ Wrap a Theano tensor into the variable for defining neural network. :param last_dim: last dimension of tensor, 0 indicates that the last dimension is flexible :rtype: deepy.core.neural_var.NeuralVariable """ # Create tensor from deepy.co...
[ "Wrap", "a", "Theano", "tensor", "into", "the", "variable", "for", "defining", "neural", "network", ".", ":", "param", "last_dim", ":", "last", "dimension", "of", "tensor", "0", "indicates", "that", "the", "last", "dimension", "is", "flexible", ":", "rtype",...
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/tensor/functions.py#L72-L116
[ "def", "var", "(", "tensor_type", ",", "last_dim", "=", "0", ",", "test_shape", "=", "None", ")", ":", "# Create tensor", "from", "deepy", ".", "core", ".", "neural_var", "import", "NeuralVariable", "from", "deepy", ".", "core", ".", "env", "import", "env"...
090fbad22a08a809b12951cd0d4984f5bd432698
test
SequentialDataset._pad
Pad sequences to given length in the left or right side.
deepy/dataset/sequence.py
def _pad(self, side, length): """ Pad sequences to given length in the left or right side. """ if self._train_set: self._train_set = pad_dataset(self._train_set, side, length) if self._valid_set: self._valid_set = pad_dataset(self._valid_set, side, length)...
def _pad(self, side, length): """ Pad sequences to given length in the left or right side. """ if self._train_set: self._train_set = pad_dataset(self._train_set, side, length) if self._valid_set: self._valid_set = pad_dataset(self._valid_set, side, length)...
[ "Pad", "sequences", "to", "given", "length", "in", "the", "left", "or", "right", "side", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/sequence.py#L15-L24
[ "def", "_pad", "(", "self", ",", "side", ",", "length", ")", ":", "if", "self", ".", "_train_set", ":", "self", ".", "_train_set", "=", "pad_dataset", "(", "self", ".", "_train_set", ",", "side", ",", "length", ")", "if", "self", ".", "_valid_set", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
rmsprop_core
RMSPROP optimization core.
deepy/trainers/cores/rmsprop.py
def rmsprop_core(params, gradients, momentum=0.9, learning_rate=0.01): """ RMSPROP optimization core. """ for param, grad in zip(params, gradients): rms_ = theano.shared(np.zeros_like(param.get_value()), name=param.name + '_rms') rms = momentum * rms_ + (1 - momentum) * grad * gr...
def rmsprop_core(params, gradients, momentum=0.9, learning_rate=0.01): """ RMSPROP optimization core. """ for param, grad in zip(params, gradients): rms_ = theano.shared(np.zeros_like(param.get_value()), name=param.name + '_rms') rms = momentum * rms_ + (1 - momentum) * grad * gr...
[ "RMSPROP", "optimization", "core", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/cores/rmsprop.py#L8-L16
[ "def", "rmsprop_core", "(", "params", ",", "gradients", ",", "momentum", "=", "0.9", ",", "learning_rate", "=", "0.01", ")", ":", "for", "param", ",", "grad", "in", "zip", "(", "params", ",", "gradients", ")", ":", "rms_", "=", "theano", ".", "shared",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
pad_dataset
Pad data set to specified length. Parameters: length - max length, a just to the max length in the batch if length is -1
deepy/dataset/padding.py
def pad_dataset(subset, side="right", length=-1): """ Pad data set to specified length. Parameters: length - max length, a just to the max length in the batch if length is -1 """ assert length == -1 or length > 0 if type(subset[0][0][0]) in [float, int, np.int64, np.int32, np.float32]: ...
def pad_dataset(subset, side="right", length=-1): """ Pad data set to specified length. Parameters: length - max length, a just to the max length in the batch if length is -1 """ assert length == -1 or length > 0 if type(subset[0][0][0]) in [float, int, np.int64, np.int32, np.float32]: ...
[ "Pad", "data", "set", "to", "specified", "length", ".", "Parameters", ":", "length", "-", "max", "length", "a", "just", "to", "the", "max", "length", "in", "the", "batch", "if", "length", "is", "-", "1" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/padding.py#L7-L17
[ "def", "pad_dataset", "(", "subset", ",", "side", "=", "\"right\"", ",", "length", "=", "-", "1", ")", ":", "assert", "length", "==", "-", "1", "or", "length", ">", "0", "if", "type", "(", "subset", "[", "0", "]", "[", "0", "]", "[", "0", "]", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
ScheduledTrainingServer.prepare_epoch
Prepare for one epoch. Returns: bool: False if to stop the training.
deepy/multigpu/server.py
def prepare_epoch(self): """ Prepare for one epoch. Returns: bool: False if to stop the training. """ self.epoch += 1 if self.epoch >= self.epoch_start_halving and ((self.epoch - self.epoch_start_halving) % self._halving_freq == 0): self._lr *= 0.5...
def prepare_epoch(self): """ Prepare for one epoch. Returns: bool: False if to stop the training. """ self.epoch += 1 if self.epoch >= self.epoch_start_halving and ((self.epoch - self.epoch_start_halving) % self._halving_freq == 0): self._lr *= 0.5...
[ "Prepare", "for", "one", "epoch", ".", "Returns", ":", "bool", ":", "False", "if", "to", "stop", "the", "training", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/multigpu/server.py#L71-L91
[ "def", "prepare_epoch", "(", "self", ")", ":", "self", ".", "epoch", "+=", "1", "if", "self", ".", "epoch", ">=", "self", ".", "epoch_start_halving", "and", "(", "(", "self", ".", "epoch", "-", "self", ".", "epoch_start_halving", ")", "%", "self", ".",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
ScheduledTrainingServer.handle_control
Handles a control_request received from a worker. Returns: string or dict: response 'stop' - the worker should quit 'wait' - wait for 1 second 'eval' - evaluate on valid and test set to start a new epoch 'sync_hyperparams' - set learning rate ...
deepy/multigpu/server.py
def handle_control(self, req, worker_id, req_info): """ Handles a control_request received from a worker. Returns: string or dict: response 'stop' - the worker should quit 'wait' - wait for 1 second 'eval' - evaluate on valid and test set to start...
def handle_control(self, req, worker_id, req_info): """ Handles a control_request received from a worker. Returns: string or dict: response 'stop' - the worker should quit 'wait' - wait for 1 second 'eval' - evaluate on valid and test set to start...
[ "Handles", "a", "control_request", "received", "from", "a", "worker", ".", "Returns", ":", "string", "or", "dict", ":", "response" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/multigpu/server.py#L116-L262
[ "def", "handle_control", "(", "self", ",", "req", ",", "worker_id", ",", "req_info", ")", ":", "if", "self", ".", "start_time", "is", "None", ":", "self", ".", "start_time", "=", "time", ".", "time", "(", ")", "response", "=", "\"\"", "if", "req", "=...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Timer.report
Report elapsed time.
deepy/utils/timer.py
def report(self): """ Report elapsed time. """ if not self.end_time: self.end() print ("Time: {} mins".format((self.end_time - self.start_time )/ 60))
def report(self): """ Report elapsed time. """ if not self.end_time: self.end() print ("Time: {} mins".format((self.end_time - self.start_time )/ 60))
[ "Report", "elapsed", "time", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/utils/timer.py#L21-L27
[ "def", "report", "(", "self", ")", ":", "if", "not", "self", ".", "end_time", ":", "self", ".", "end", "(", ")", "print", "(", "\"Time: {} mins\"", ".", "format", "(", "(", "self", ".", "end_time", "-", "self", ".", "start_time", ")", "/", "60", ")...
090fbad22a08a809b12951cd0d4984f5bd432698
test
TrainingValidator.compare
Compare to previous records and return whether the given cost is a new best. :return: True if the given cost is a new best
deepy/trainers/controllers.py
def compare(self, cost_map): """ Compare to previous records and return whether the given cost is a new best. :return: True if the given cost is a new best """ cri_val = cost_map[self._criteria] if self._best_criteria is None: self._best_criteria = cri_val ...
def compare(self, cost_map): """ Compare to previous records and return whether the given cost is a new best. :return: True if the given cost is a new best """ cri_val = cost_map[self._criteria] if self._best_criteria is None: self._best_criteria = cri_val ...
[ "Compare", "to", "previous", "records", "and", "return", "whether", "the", "given", "cost", "is", "a", "new", "best", ".", ":", "return", ":", "True", "if", "the", "given", "cost", "is", "a", "new", "best" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/controllers.py#L42-L59
[ "def", "compare", "(", "self", ",", "cost_map", ")", ":", "cri_val", "=", "cost_map", "[", "self", ".", "_criteria", "]", "if", "self", ".", "_best_criteria", "is", "None", ":", "self", ".", "_best_criteria", "=", "cri_val", "return", "True", "else", ":"...
090fbad22a08a809b12951cd0d4984f5bd432698
test
TrainingValidator.run
Run the model with validation data and return costs.
deepy/trainers/controllers.py
def run(self, data_x): """ Run the model with validation data and return costs. """ output_vars = self.compute(*data_x) return self._extract_costs(output_vars)
def run(self, data_x): """ Run the model with validation data and return costs. """ output_vars = self.compute(*data_x) return self._extract_costs(output_vars)
[ "Run", "the", "model", "with", "validation", "data", "and", "return", "costs", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/controllers.py#L79-L84
[ "def", "run", "(", "self", ",", "data_x", ")", ":", "output_vars", "=", "self", ".", "compute", "(", "*", "data_x", ")", "return", "self", ".", "_extract_costs", "(", "output_vars", ")" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
TrainingValidator.invoke
This function will be called after each iteration.
deepy/trainers/controllers.py
def invoke(self): """ This function will be called after each iteration. """ self._counter += 1 if self._counter % self._freq == 0: cnt = 0. sum_map = defaultdict(float) for x in self._trainer.get_data(self._data_split): val_map...
def invoke(self): """ This function will be called after each iteration. """ self._counter += 1 if self._counter % self._freq == 0: cnt = 0. sum_map = defaultdict(float) for x in self._trainer.get_data(self._data_split): val_map...
[ "This", "function", "will", "be", "called", "after", "each", "iteration", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/controllers.py#L86-L106
[ "def", "invoke", "(", "self", ")", ":", "self", ".", "_counter", "+=", "1", "if", "self", ".", "_counter", "%", "self", ".", "_freq", "==", "0", ":", "cnt", "=", "0.", "sum_map", "=", "defaultdict", "(", "float", ")", "for", "x", "in", "self", "....
090fbad22a08a809b12951cd0d4984f5bd432698
test
Loop._build_loop_vars
Create inner loop variables.
deepy/core/loop.py
def _build_loop_vars(self): """ Create inner loop variables. """ from theano.tensor.var import TensorVariable from deepy.core.neural_var import NeuralVariable if not self._loop_vars: self._ordered_out_keys = self._outputs.keys() seq_keys = self._se...
def _build_loop_vars(self): """ Create inner loop variables. """ from theano.tensor.var import TensorVariable from deepy.core.neural_var import NeuralVariable if not self._loop_vars: self._ordered_out_keys = self._outputs.keys() seq_keys = self._se...
[ "Create", "inner", "loop", "variables", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/loop.py#L32-L56
[ "def", "_build_loop_vars", "(", "self", ")", ":", "from", "theano", ".", "tensor", ".", "var", "import", "TensorVariable", "from", "deepy", ".", "core", ".", "neural_var", "import", "NeuralVariable", "if", "not", "self", ".", "_loop_vars", ":", "self", ".", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Loop._scan_step
Internal scan with dummy input variables.
deepy/core/loop.py
def _scan_step(self, vars): """ Internal scan with dummy input variables. """ from neural_var import NeuralVariable if not self._loop_vars: raise Exception("The loop is not initialized. To initialize the loop, use `with loop as vars`") replace_map = {} ...
def _scan_step(self, vars): """ Internal scan with dummy input variables. """ from neural_var import NeuralVariable if not self._loop_vars: raise Exception("The loop is not initialized. To initialize the loop, use `with loop as vars`") replace_map = {} ...
[ "Internal", "scan", "with", "dummy", "input", "variables", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/loop.py#L86-L103
[ "def", "_scan_step", "(", "self", ",", "vars", ")", ":", "from", "neural_var", "import", "NeuralVariable", "if", "not", "self", ".", "_loop_vars", ":", "raise", "Exception", "(", "\"The loop is not initialized. To initialize the loop, use `with loop as vars`\"", ")", "r...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Loop.get_outputs
Get the outputs of the loop. Return specific variables by passing the keys to the arguments. :rtype: MapDict
deepy/core/loop.py
def get_outputs(self, *args): """ Get the outputs of the loop. Return specific variables by passing the keys to the arguments. :rtype: MapDict """ if args: output_vars = map(self._scan_outputs.get, args) if len(output_vars) == 1: re...
def get_outputs(self, *args): """ Get the outputs of the loop. Return specific variables by passing the keys to the arguments. :rtype: MapDict """ if args: output_vars = map(self._scan_outputs.get, args) if len(output_vars) == 1: re...
[ "Get", "the", "outputs", "of", "the", "loop", ".", "Return", "specific", "variables", "by", "passing", "the", "keys", "to", "the", "arguments", ".", ":", "rtype", ":", "MapDict" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/loop.py#L116-L129
[ "def", "get_outputs", "(", "self", ",", "*", "args", ")", ":", "if", "args", ":", "output_vars", "=", "map", "(", "self", ".", "_scan_outputs", ".", "get", ",", "args", ")", "if", "len", "(", "output_vars", ")", "==", "1", ":", "return", "output_vars...
090fbad22a08a809b12951cd0d4984f5bd432698
test
momentum_core
Momentum SGD optimization core.
deepy/trainers/cores/momentum.py
def momentum_core(params, gradients, momentum=0.9, learning_rate=0.01): """ Momentum SGD optimization core. """ free_parameters = [] updates = [] for param, grad in zip(params, gradients): delta = learning_rate * grad velocity = theano.shared(np.zeros_like(param.get_value...
def momentum_core(params, gradients, momentum=0.9, learning_rate=0.01): """ Momentum SGD optimization core. """ free_parameters = [] updates = [] for param, grad in zip(params, gradients): delta = learning_rate * grad velocity = theano.shared(np.zeros_like(param.get_value...
[ "Momentum", "SGD", "optimization", "core", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/cores/momentum.py#L7-L19
[ "def", "momentum_core", "(", "params", ",", "gradients", ",", "momentum", "=", "0.9", ",", "learning_rate", "=", "0.01", ")", ":", "free_parameters", "=", "[", "]", "updates", "=", "[", "]", "for", "param", ",", "grad", "in", "zip", "(", "params", ",",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Runtime.iftrain
Execute `then_branch` when training.
deepy/core/runtime.py
def iftrain(self, then_branch, else_branch): """ Execute `then_branch` when training. """ return ifelse(self._training_flag, then_branch, else_branch, name="iftrain")
def iftrain(self, then_branch, else_branch): """ Execute `then_branch` when training. """ return ifelse(self._training_flag, then_branch, else_branch, name="iftrain")
[ "Execute", "then_branch", "when", "training", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/runtime.py#L20-L24
[ "def", "iftrain", "(", "self", ",", "then_branch", ",", "else_branch", ")", ":", "return", "ifelse", "(", "self", ".", "_training_flag", ",", "then_branch", ",", "else_branch", ",", "name", "=", "\"iftrain\"", ")" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
Runtime.switch_training
Switch training mode. :param flag: switch on training mode when flag is True.
deepy/core/runtime.py
def switch_training(self, flag): """ Switch training mode. :param flag: switch on training mode when flag is True. """ if self._is_training == flag: return self._is_training = flag if flag: self._training_flag.set_value(1) else: sel...
def switch_training(self, flag): """ Switch training mode. :param flag: switch on training mode when flag is True. """ if self._is_training == flag: return self._is_training = flag if flag: self._training_flag.set_value(1) else: sel...
[ "Switch", "training", "mode", ".", ":", "param", "flag", ":", "switch", "on", "training", "mode", "when", "flag", "is", "True", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/runtime.py#L26-L36
[ "def", "switch_training", "(", "self", ",", "flag", ")", ":", "if", "self", ".", "_is_training", "==", "flag", ":", "return", "self", ".", "_is_training", "=", "flag", "if", "flag", ":", "self", ".", "_training_flag", ".", "set_value", "(", "1", ")", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
nag_core
Nesterov's Accelerated Gradient (NAG). See http://www.cs.toronto.edu/~fritz/absps/momentum.pdf . Still unfinished
deepy/trainers/cores/nag.py
def nag_core(params, J, momentum=0.9, learning_rate=0.01): """ Nesterov's Accelerated Gradient (NAG). See http://www.cs.toronto.edu/~fritz/absps/momentum.pdf . Still unfinished """ # TODO: this requires some refractorings. for param in params: step = theano.shared(np.zeros_like(param...
def nag_core(params, J, momentum=0.9, learning_rate=0.01): """ Nesterov's Accelerated Gradient (NAG). See http://www.cs.toronto.edu/~fritz/absps/momentum.pdf . Still unfinished """ # TODO: this requires some refractorings. for param in params: step = theano.shared(np.zeros_like(param...
[ "Nesterov", "s", "Accelerated", "Gradient", "(", "NAG", ")", ".", "See", "http", ":", "//", "www", ".", "cs", ".", "toronto", ".", "edu", "/", "~fritz", "/", "absps", "/", "momentum", ".", "pdf", ".", "Still", "unfinished" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/cores/nag.py#L8-L21
[ "def", "nag_core", "(", "params", ",", "J", ",", "momentum", "=", "0.9", ",", "learning_rate", "=", "0.01", ")", ":", "# TODO: this requires some refractorings.", "for", "param", "in", "params", ":", "step", "=", "theano", ".", "shared", "(", "np", ".", "z...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.skip
Skip N batches in the training.
deepy/trainers/base.py
def skip(self, n_batches, n_epochs=0): """ Skip N batches in the training. """ logging.info("skip %d epochs and %d batches" % (n_epochs, n_batches)) self._skip_batches = n_batches self._skip_epochs = n_epochs
def skip(self, n_batches, n_epochs=0): """ Skip N batches in the training. """ logging.info("skip %d epochs and %d batches" % (n_epochs, n_batches)) self._skip_batches = n_batches self._skip_epochs = n_epochs
[ "Skip", "N", "batches", "in", "the", "training", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L90-L96
[ "def", "skip", "(", "self", ",", "n_batches", ",", "n_epochs", "=", "0", ")", ":", "logging", ".", "info", "(", "\"skip %d epochs and %d batches\"", "%", "(", "n_epochs", ",", "n_batches", ")", ")", "self", ".", "_skip_batches", "=", "n_batches", "self", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.load_params
Load parameters for the training. This method can load free parameters and resume the training progress.
deepy/trainers/base.py
def load_params(self, path, exclude_free_params=False): """ Load parameters for the training. This method can load free parameters and resume the training progress. """ self.network.load_params(path, exclude_free_params=exclude_free_params) self.best_params = self.copy_pa...
def load_params(self, path, exclude_free_params=False): """ Load parameters for the training. This method can load free parameters and resume the training progress. """ self.network.load_params(path, exclude_free_params=exclude_free_params) self.best_params = self.copy_pa...
[ "Load", "parameters", "for", "the", "training", ".", "This", "method", "can", "load", "free", "parameters", "and", "resume", "the", "training", "progress", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L144-L153
[ "def", "load_params", "(", "self", ",", "path", ",", "exclude_free_params", "=", "False", ")", ":", "self", ".", "network", ".", "load_params", "(", "path", ",", "exclude_free_params", "=", "exclude_free_params", ")", "self", ".", "best_params", "=", "self", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.add_iter_controllers
Add iteration callbacks function (receives an argument of the trainer). :param controllers: can be a `TrainingController` or a function. :type funcs: list of TrainingContoller
deepy/trainers/base.py
def add_iter_controllers(self, *controllers): """ Add iteration callbacks function (receives an argument of the trainer). :param controllers: can be a `TrainingController` or a function. :type funcs: list of TrainingContoller """ for controller in controllers: ...
def add_iter_controllers(self, *controllers): """ Add iteration callbacks function (receives an argument of the trainer). :param controllers: can be a `TrainingController` or a function. :type funcs: list of TrainingContoller """ for controller in controllers: ...
[ "Add", "iteration", "callbacks", "function", "(", "receives", "an", "argument", "of", "the", "trainer", ")", ".", ":", "param", "controllers", ":", "can", "be", "a", "TrainingController", "or", "a", "function", ".", ":", "type", "funcs", ":", "list", "of",...
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L166-L175
[ "def", "add_iter_controllers", "(", "self", ",", "*", "controllers", ")", ":", "for", "controller", "in", "controllers", ":", "if", "isinstance", "(", "controller", ",", "TrainingController", ")", ":", "controller", ".", "bind", "(", "self", ")", "self", "."...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.add_epoch_controllers
Add epoch callbacks function. :param controllers: can be a `TrainingController` or a function.
deepy/trainers/base.py
def add_epoch_controllers(self, *controllers): """ Add epoch callbacks function. :param controllers: can be a `TrainingController` or a function. """ for controller in controllers: if isinstance(controller, TrainingController): controller.bind(self) ...
def add_epoch_controllers(self, *controllers): """ Add epoch callbacks function. :param controllers: can be a `TrainingController` or a function. """ for controller in controllers: if isinstance(controller, TrainingController): controller.bind(self) ...
[ "Add", "epoch", "callbacks", "function", ".", ":", "param", "controllers", ":", "can", "be", "a", "TrainingController", "or", "a", "function", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L177-L185
[ "def", "add_epoch_controllers", "(", "self", ",", "*", "controllers", ")", ":", "for", "controller", "in", "controllers", ":", "if", "isinstance", "(", "controller", ",", "TrainingController", ")", ":", "controller", ".", "bind", "(", "self", ")", "self", "....
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.train
Train the model and return costs.
deepy/trainers/base.py
def train(self, train_set, valid_set=None, test_set=None, train_size=None): """ Train the model and return costs. """ self._epoch = 0 while True: if self._skip_epochs > 0: logging.info("skipping one epoch ...") self._skip_epochs -= 1 ...
def train(self, train_set, valid_set=None, test_set=None, train_size=None): """ Train the model and return costs. """ self._epoch = 0 while True: if self._skip_epochs > 0: logging.info("skipping one epoch ...") self._skip_epochs -= 1 ...
[ "Train", "the", "model", "and", "return", "costs", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L187-L236
[ "def", "train", "(", "self", ",", "train_set", ",", "valid_set", "=", "None", ",", "test_set", "=", "None", ",", "train_size", "=", "None", ")", ":", "self", ".", "_epoch", "=", "0", "while", "True", ":", "if", "self", ".", "_skip_epochs", ">", "0", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer._run_train
Run one training iteration.
deepy/trainers/base.py
def _run_train(self, epoch, train_set, train_size=None): """ Run one training iteration. """ self.network.train_logger.record_epoch(epoch + 1) costs = self.train_step(train_set, train_size) if not epoch % self.config.monitor_frequency: self.report(dict(costs),...
def _run_train(self, epoch, train_set, train_size=None): """ Run one training iteration. """ self.network.train_logger.record_epoch(epoch + 1) costs = self.train_step(train_set, train_size) if not epoch % self.config.monitor_frequency: self.report(dict(costs),...
[ "Run", "one", "training", "iteration", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L254-L263
[ "def", "_run_train", "(", "self", ",", "epoch", ",", "train_set", ",", "train_size", "=", "None", ")", ":", "self", ".", "network", ".", "train_logger", ".", "record_epoch", "(", "epoch", "+", "1", ")", "costs", "=", "self", ".", "train_step", "(", "tr...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer._run_valid
Run one valid iteration, return true if to continue training.
deepy/trainers/base.py
def _run_valid(self, epoch, valid_set, dry_run=False, save_path=None): """ Run one valid iteration, return true if to continue training. """ costs = self.valid_step(valid_set) # this is the same as: (J_i - J_f) / J_i > min improvement _, J = costs[0] new_best = Fa...
def _run_valid(self, epoch, valid_set, dry_run=False, save_path=None): """ Run one valid iteration, return true if to continue training. """ costs = self.valid_step(valid_set) # this is the same as: (J_i - J_f) / J_i > min improvement _, J = costs[0] new_best = Fa...
[ "Run", "one", "valid", "iteration", "return", "true", "if", "to", "continue", "training", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L265-L284
[ "def", "_run_valid", "(", "self", ",", "epoch", ",", "valid_set", ",", "dry_run", "=", "False", ",", "save_path", "=", "None", ")", ":", "costs", "=", "self", ".", "valid_step", "(", "valid_set", ")", "# this is the same as: (J_i - J_f) / J_i > min improvement", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.report
Report the scores and record them in the log.
deepy/trainers/base.py
def report(self, score_map, type="valid", epoch=-1, new_best=False): """ Report the scores and record them in the log. """ type_str = type if len(type_str) < 5: type_str += " " * (5 - len(type_str)) info = " ".join("%s=%.2f" % el for el in score_map.items()) ...
def report(self, score_map, type="valid", epoch=-1, new_best=False): """ Report the scores and record them in the log. """ type_str = type if len(type_str) < 5: type_str += " " * (5 - len(type_str)) info = " ".join("%s=%.2f" % el for el in score_map.items()) ...
[ "Report", "the", "scores", "and", "record", "them", "in", "the", "log", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L293-L310
[ "def", "report", "(", "self", ",", "score_map", ",", "type", "=", "\"valid\"", ",", "epoch", "=", "-", "1", ",", "new_best", "=", "False", ")", ":", "type_str", "=", "type", "if", "len", "(", "type_str", ")", "<", "5", ":", "type_str", "+=", "\" \"...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.get_data
Get specified split of data.
deepy/trainers/base.py
def get_data(self, data_split="train"): """ Get specified split of data. """ if data_split == 'train': return self._current_train_set elif data_split == 'valid': return self._current_valid_set elif data_split == 'test': return self._cur...
def get_data(self, data_split="train"): """ Get specified split of data. """ if data_split == 'train': return self._current_train_set elif data_split == 'valid': return self._current_valid_set elif data_split == 'test': return self._cur...
[ "Get", "specified", "split", "of", "data", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L390-L401
[ "def", "get_data", "(", "self", ",", "data_split", "=", "\"train\"", ")", ":", "if", "data_split", "==", "'train'", ":", "return", "self", ".", "_current_train_set", "elif", "data_split", "==", "'valid'", ":", "return", "self", ".", "_current_valid_set", "elif...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralTrainer.run
Run until the end. :param epoch_controllers: deprecated
deepy/trainers/base.py
def run(self, train_set, valid_set=None, test_set=None, train_size=None, epoch_controllers=None): """ Run until the end. :param epoch_controllers: deprecated """ epoch_controllers = epoch_controllers if epoch_controllers else [] epoch_controllers += self._epoch_controller...
def run(self, train_set, valid_set=None, test_set=None, train_size=None, epoch_controllers=None): """ Run until the end. :param epoch_controllers: deprecated """ epoch_controllers = epoch_controllers if epoch_controllers else [] epoch_controllers += self._epoch_controller...
[ "Run", "until", "the", "end", ".", ":", "param", "epoch_controllers", ":", "deprecated" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/base.py#L403-L430
[ "def", "run", "(", "self", ",", "train_set", ",", "valid_set", "=", "None", ",", "test_set", "=", "None", ",", "train_size", "=", "None", ",", "epoch_controllers", "=", "None", ")", ":", "epoch_controllers", "=", "epoch_controllers", "if", "epoch_controllers",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
BunchSequences._cut_to_pieces
:type bunch_stack: list of list of int
deepy/dataset/bunch_seq.py
def _cut_to_pieces(self, bunch_stack): """ :type bunch_stack: list of list of int """ stack_len = len(bunch_stack[0]) for i in xrange(0, stack_len, self.fragment_length): yield np.array(map(lambda stack: stack[i: i + self.fragment_length], bunch_stack))
def _cut_to_pieces(self, bunch_stack): """ :type bunch_stack: list of list of int """ stack_len = len(bunch_stack[0]) for i in xrange(0, stack_len, self.fragment_length): yield np.array(map(lambda stack: stack[i: i + self.fragment_length], bunch_stack))
[ ":", "type", "bunch_stack", ":", "list", "of", "list", "of", "int" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/bunch_seq.py#L58-L64
[ "def", "_cut_to_pieces", "(", "self", ",", "bunch_stack", ")", ":", "stack_len", "=", "len", "(", "bunch_stack", "[", "0", "]", ")", "for", "i", "in", "xrange", "(", "0", ",", "stack_len", ",", "self", ".", "fragment_length", ")", ":", "yield", "np", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
BunchSequences._pad_zeros
:type bunch_stack: list of list
deepy/dataset/bunch_seq.py
def _pad_zeros(self, bunch_stack): """ :type bunch_stack: list of list """ min_len = min(map(len, bunch_stack)) for i in range(len(bunch_stack)): bunch_stack[i] = bunch_stack[i][:min_len]
def _pad_zeros(self, bunch_stack): """ :type bunch_stack: list of list """ min_len = min(map(len, bunch_stack)) for i in range(len(bunch_stack)): bunch_stack[i] = bunch_stack[i][:min_len]
[ ":", "type", "bunch_stack", ":", "list", "of", "list" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/bunch_seq.py#L66-L72
[ "def", "_pad_zeros", "(", "self", ",", "bunch_stack", ")", ":", "min_len", "=", "min", "(", "map", "(", "len", ",", "bunch_stack", ")", ")", "for", "i", "in", "range", "(", "len", "(", "bunch_stack", ")", ")", ":", "bunch_stack", "[", "i", "]", "="...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralVariable.apply
Apply a function to tensors.
deepy/core/neural_var.py
def apply(self, func, dim=None): """ Apply a function to tensors. """ output_dim = dim if dim else self.output_dim return NeuralVariable(func(self.tensor), output_dim)
def apply(self, func, dim=None): """ Apply a function to tensors. """ output_dim = dim if dim else self.output_dim return NeuralVariable(func(self.tensor), output_dim)
[ "Apply", "a", "function", "to", "tensors", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/neural_var.py#L29-L34
[ "def", "apply", "(", "self", ",", "func", ",", "dim", "=", "None", ")", ":", "output_dim", "=", "dim", "if", "dim", "else", "self", ".", "output_dim", "return", "NeuralVariable", "(", "func", "(", "self", ".", "tensor", ")", ",", "output_dim", ")" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
rprop_core
Rprop optimizer. See http://sci2s.ugr.es/keel/pdf/algorithm/articulo/2003-Neuro-Igel-IRprop+.pdf.
deepy/trainers/cores/rprop.py
def rprop_core(params, gradients, rprop_increase=1.01, rprop_decrease=0.99, rprop_min_step=0, rprop_max_step=100, learning_rate=0.01): """ Rprop optimizer. See http://sci2s.ugr.es/keel/pdf/algorithm/articulo/2003-Neuro-Igel-IRprop+.pdf. """ for param, grad in zip(params, gradients): ...
def rprop_core(params, gradients, rprop_increase=1.01, rprop_decrease=0.99, rprop_min_step=0, rprop_max_step=100, learning_rate=0.01): """ Rprop optimizer. See http://sci2s.ugr.es/keel/pdf/algorithm/articulo/2003-Neuro-Igel-IRprop+.pdf. """ for param, grad in zip(params, gradients): ...
[ "Rprop", "optimizer", ".", "See", "http", ":", "//", "sci2s", ".", "ugr", ".", "es", "/", "keel", "/", "pdf", "/", "algorithm", "/", "articulo", "/", "2003", "-", "Neuro", "-", "Igel", "-", "IRprop", "+", ".", "pdf", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/cores/rprop.py#L8-L28
[ "def", "rprop_core", "(", "params", ",", "gradients", ",", "rprop_increase", "=", "1.01", ",", "rprop_decrease", "=", "0.99", ",", "rprop_min_step", "=", "0", ",", "rprop_max_step", "=", "100", ",", "learning_rate", "=", "0.01", ")", ":", "for", "param", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GeneralConfig.report
Report usage of training parameters.
deepy/conf/config.py
def report(self): """ Report usage of training parameters. """ if self.logger: self.logger.info("accessed parameters:") for key in self.used_parameters: self.logger.info(" - %s %s" % (key, "(undefined)" if key in self.undefined_parameters else ""))
def report(self): """ Report usage of training parameters. """ if self.logger: self.logger.info("accessed parameters:") for key in self.used_parameters: self.logger.info(" - %s %s" % (key, "(undefined)" if key in self.undefined_parameters else ""))
[ "Report", "usage", "of", "training", "parameters", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/conf/config.py#L39-L46
[ "def", "report", "(", "self", ")", ":", "if", "self", ".", "logger", ":", "self", ".", "logger", ".", "info", "(", "\"accessed parameters:\"", ")", "for", "key", "in", "self", ".", "used_parameters", ":", "self", ".", "logger", ".", "info", "(", "\" - ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.new_block
Create a parameters block. :param layers: register some layers in the block :param name: specify the name of this block
deepy/core/graph.py
def new_block(self, *layers, **kwargs): """ Create a parameters block. :param layers: register some layers in the block :param name: specify the name of this block """ from deepy.layers.block import Block block = Block(*layers, **kwargs) return block
def new_block(self, *layers, **kwargs): """ Create a parameters block. :param layers: register some layers in the block :param name: specify the name of this block """ from deepy.layers.block import Block block = Block(*layers, **kwargs) return block
[ "Create", "a", "parameters", "block", ".", ":", "param", "layers", ":", "register", "some", "layers", "in", "the", "block", ":", "param", "name", ":", "specify", "the", "name", "of", "this", "block" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L39-L47
[ "def", "new_block", "(", "self", ",", "*", "layers", ",", "*", "*", "kwargs", ")", ":", "from", "deepy", ".", "layers", ".", "block", "import", "Block", "block", "=", "Block", "(", "*", "layers", ",", "*", "*", "kwargs", ")", "return", "block" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.var
An alias of deepy.tensor.var.
deepy/core/graph.py
def var(self, tensor_type, last_dim=0, test_shape=None): """ An alias of deepy.tensor.var. """ from deepy.tensor import var return var(tensor_type, last_dim=last_dim, test_shape=test_shape)
def var(self, tensor_type, last_dim=0, test_shape=None): """ An alias of deepy.tensor.var. """ from deepy.tensor import var return var(tensor_type, last_dim=last_dim, test_shape=test_shape)
[ "An", "alias", "of", "deepy", ".", "tensor", ".", "var", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L49-L54
[ "def", "var", "(", "self", ",", "tensor_type", ",", "last_dim", "=", "0", ",", "test_shape", "=", "None", ")", ":", "from", "deepy", ".", "tensor", "import", "var", "return", "var", "(", "tensor_type", ",", "last_dim", "=", "last_dim", ",", "test_shape",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.create_vars_from_data
Create vars given a dataset and set test values. Useful when dataset is already defined.
deepy/core/graph.py
def create_vars_from_data(self, dataset, split="train"): """ Create vars given a dataset and set test values. Useful when dataset is already defined. """ from deepy.core.neural_var import NeuralVariable vars = [] if split == "valid": data_split = datas...
def create_vars_from_data(self, dataset, split="train"): """ Create vars given a dataset and set test values. Useful when dataset is already defined. """ from deepy.core.neural_var import NeuralVariable vars = [] if split == "valid": data_split = datas...
[ "Create", "vars", "given", "a", "dataset", "and", "set", "test", "values", ".", "Useful", "when", "dataset", "is", "already", "defined", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L56-L91
[ "def", "create_vars_from_data", "(", "self", ",", "dataset", ",", "split", "=", "\"train\"", ")", ":", "from", "deepy", ".", "core", ".", "neural_var", "import", "NeuralVariable", "vars", "=", "[", "]", "if", "split", "==", "\"valid\"", ":", "data_split", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.scan
A loop function, the usage is identical with the theano one. :type block: deepy.layers.Block
deepy/core/graph.py
def scan(self, func, sequences=None, outputs=None, non_sequences=None, block=None, **kwargs): """ A loop function, the usage is identical with the theano one. :type block: deepy.layers.Block """ results, updates = Scanner(func, sequences, outputs, non_sequences, neural_computatio...
def scan(self, func, sequences=None, outputs=None, non_sequences=None, block=None, **kwargs): """ A loop function, the usage is identical with the theano one. :type block: deepy.layers.Block """ results, updates = Scanner(func, sequences, outputs, non_sequences, neural_computatio...
[ "A", "loop", "function", "the", "usage", "is", "identical", "with", "the", "theano", "one", ".", ":", "type", "block", ":", "deepy", ".", "layers", ".", "Block" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L94-L104
[ "def", "scan", "(", "self", ",", "func", ",", "sequences", "=", "None", ",", "outputs", "=", "None", ",", "non_sequences", "=", "None", ",", "block", "=", "None", ",", "*", "*", "kwargs", ")", ":", "results", ",", "updates", "=", "Scanner", "(", "f...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.loop
Start a loop. Usage: ``` with deepy.graph.loop(sequences={"x": x}, outputs={"o": None}) as vars: vars.o = vars.x + 1 loop_outputs = deepy.graph.loop_outputs() result = loop_outputs.o ```
deepy/core/graph.py
def loop(self, sequences=None, outputs=None, non_sequences=None, block=None, **kwargs): """ Start a loop. Usage: ``` with deepy.graph.loop(sequences={"x": x}, outputs={"o": None}) as vars: vars.o = vars.x + 1 loop_outputs = deepy.graph.loop_outputs() r...
def loop(self, sequences=None, outputs=None, non_sequences=None, block=None, **kwargs): """ Start a loop. Usage: ``` with deepy.graph.loop(sequences={"x": x}, outputs={"o": None}) as vars: vars.o = vars.x + 1 loop_outputs = deepy.graph.loop_outputs() r...
[ "Start", "a", "loop", ".", "Usage", ":", "with", "deepy", ".", "graph", ".", "loop", "(", "sequences", "=", "{", "x", ":", "x", "}", "outputs", "=", "{", "o", ":", "None", "}", ")", "as", "vars", ":", "vars", ".", "o", "=", "vars", ".", "x", ...
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L106-L118
[ "def", "loop", "(", "self", ",", "sequences", "=", "None", ",", "outputs", "=", "None", ",", "non_sequences", "=", "None", ",", "block", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "loop", "import", "Loop", "return", "Loop", "(", "sequenc...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.get_trainer
Get a trainer to optimize given model. :rtype: deepy.trainers.GeneralNeuralTrainer
deepy/core/graph.py
def get_trainer(self, model, method='sgd', config=None, annealer=None, validator=None): """ Get a trainer to optimize given model. :rtype: deepy.trainers.GeneralNeuralTrainer """ from deepy.trainers import GeneralNeuralTrainer return GeneralNeuralTrainer(model, method=me...
def get_trainer(self, model, method='sgd', config=None, annealer=None, validator=None): """ Get a trainer to optimize given model. :rtype: deepy.trainers.GeneralNeuralTrainer """ from deepy.trainers import GeneralNeuralTrainer return GeneralNeuralTrainer(model, method=me...
[ "Get", "a", "trainer", "to", "optimize", "given", "model", ".", ":", "rtype", ":", "deepy", ".", "trainers", ".", "GeneralNeuralTrainer" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L120-L126
[ "def", "get_trainer", "(", "self", ",", "model", ",", "method", "=", "'sgd'", ",", "config", "=", "None", ",", "annealer", "=", "None", ",", "validator", "=", "None", ")", ":", "from", "deepy", ".", "trainers", "import", "GeneralNeuralTrainer", "return", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.shared
Create a shared theano scalar value.
deepy/core/graph.py
def shared(self, value, name=None): """ Create a shared theano scalar value. """ if type(value) == int: final_value = np.array(value, dtype="int32") elif type(value) == float: final_value = np.array(value, dtype=env.FLOATX) else: final_...
def shared(self, value, name=None): """ Create a shared theano scalar value. """ if type(value) == int: final_value = np.array(value, dtype="int32") elif type(value) == float: final_value = np.array(value, dtype=env.FLOATX) else: final_...
[ "Create", "a", "shared", "theano", "scalar", "value", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L129-L140
[ "def", "shared", "(", "self", ",", "value", ",", "name", "=", "None", ")", ":", "if", "type", "(", "value", ")", "==", "int", ":", "final_value", "=", "np", ".", "array", "(", "value", ",", "dtype", "=", "\"int32\"", ")", "elif", "type", "(", "va...
090fbad22a08a809b12951cd0d4984f5bd432698
test
GraphBuilder.fill_parameters
Load parameters from file to fill all blocks sequentially. :type blocks: list of deepy.layers.Block
deepy/core/graph.py
def fill_parameters(self, path, blocks, exclude_free_params=False, check_parameters=False): """ Load parameters from file to fill all blocks sequentially. :type blocks: list of deepy.layers.Block """ if not os.path.exists(path): raise Exception("model {} does not exis...
def fill_parameters(self, path, blocks, exclude_free_params=False, check_parameters=False): """ Load parameters from file to fill all blocks sequentially. :type blocks: list of deepy.layers.Block """ if not os.path.exists(path): raise Exception("model {} does not exis...
[ "Load", "parameters", "from", "file", "to", "fill", "all", "blocks", "sequentially", ".", ":", "type", "blocks", ":", "list", "of", "deepy", ".", "layers", ".", "Block" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/core/graph.py#L158-L194
[ "def", "fill_parameters", "(", "self", ",", "path", ",", "blocks", ",", "exclude_free_params", "=", "False", ",", "check_parameters", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "Exception", "(",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Dataset.train_size
Return size of training data. (optional) :rtype: number
deepy/dataset/dataset.py
def train_size(self): """ Return size of training data. (optional) :rtype: number """ train_set = self.train_set() if isinstance(train_set, collections.Iterable): return len(list(train_set)) else: return None
def train_size(self): """ Return size of training data. (optional) :rtype: number """ train_set = self.train_set() if isinstance(train_set, collections.Iterable): return len(list(train_set)) else: return None
[ "Return", "size", "of", "training", "data", ".", "(", "optional", ")", ":", "rtype", ":", "number" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/dataset/dataset.py#L29-L38
[ "def", "train_size", "(", "self", ")", ":", "train_set", "=", "self", ".", "train_set", "(", ")", "if", "isinstance", "(", "train_set", ",", "collections", ".", "Iterable", ")", ":", "return", "len", "(", "list", "(", "train_set", ")", ")", "else", ":"...
090fbad22a08a809b12951cd0d4984f5bd432698
test
LearningRateAnnealer.invoke
Run it, return whether to end training.
deepy/trainers/annealers.py
def invoke(self): """ Run it, return whether to end training. """ self._iter += 1 if self._iter - max(self._trainer.best_iter, self._annealed_iter) >= self._patience: if self._annealed_times >= self._anneal_times: logging.info("ending") ...
def invoke(self): """ Run it, return whether to end training. """ self._iter += 1 if self._iter - max(self._trainer.best_iter, self._annealed_iter) >= self._patience: if self._annealed_times >= self._anneal_times: logging.info("ending") ...
[ "Run", "it", "return", "whether", "to", "end", "training", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/annealers.py#L37-L51
[ "def", "invoke", "(", "self", ")", ":", "self", ".", "_iter", "+=", "1", "if", "self", ".", "_iter", "-", "max", "(", "self", ".", "_trainer", ".", "best_iter", ",", "self", ".", "_annealed_iter", ")", ">=", "self", ".", "_patience", ":", "if", "se...
090fbad22a08a809b12951cd0d4984f5bd432698
test
SimpleScheduler.invoke
Run it, return whether to end training.
deepy/trainers/annealers.py
def invoke(self): """ Run it, return whether to end training. """ self._iter += 1 logging.info("{} epochs left to run".format(self._patience - self._iter)) if self._iter >= self._patience: self._trainer.exit()
def invoke(self): """ Run it, return whether to end training. """ self._iter += 1 logging.info("{} epochs left to run".format(self._patience - self._iter)) if self._iter >= self._patience: self._trainer.exit()
[ "Run", "it", "return", "whether", "to", "end", "training", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/annealers.py#L131-L138
[ "def", "invoke", "(", "self", ")", ":", "self", ".", "_iter", "+=", "1", "logging", ".", "info", "(", "\"{} epochs left to run\"", ".", "format", "(", "self", ".", "_patience", "-", "self", ".", "_iter", ")", ")", "if", "self", ".", "_iter", ">=", "s...
090fbad22a08a809b12951cd0d4984f5bd432698
test
VariationalAutoEncoder.stack_reparameterization_layer
Perform reparameterization trick for latent variables. :param layer_size: the size of latent variable
examples/variational_autoencoder/variational_autoencoder.py
def stack_reparameterization_layer(self, layer_size): """ Perform reparameterization trick for latent variables. :param layer_size: the size of latent variable """ self.rep_layer = ReparameterizationLayer(layer_size, sample=self.sample) self.stack_encoders(self.rep_layer)
def stack_reparameterization_layer(self, layer_size): """ Perform reparameterization trick for latent variables. :param layer_size: the size of latent variable """ self.rep_layer = ReparameterizationLayer(layer_size, sample=self.sample) self.stack_encoders(self.rep_layer)
[ "Perform", "reparameterization", "trick", "for", "latent", "variables", ".", ":", "param", "layer_size", ":", "the", "size", "of", "latent", "variable" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/variational_autoencoder/variational_autoencoder.py#L69-L75
[ "def", "stack_reparameterization_layer", "(", "self", ",", "layer_size", ")", ":", "self", ".", "rep_layer", "=", "ReparameterizationLayer", "(", "layer_size", ",", "sample", "=", "self", ".", "sample", ")", "self", ".", "stack_encoders", "(", "self", ".", "re...
090fbad22a08a809b12951cd0d4984f5bd432698
test
AutoEncoder.stack_encoders
Stack encoding layers, this must be done before stacking decoding layers.
deepy/networks/auto_encoder.py
def stack_encoders(self, *layers): """ Stack encoding layers, this must be done before stacking decoding layers. """ self.stack(*layers) self.encoding_layes.extend(layers)
def stack_encoders(self, *layers): """ Stack encoding layers, this must be done before stacking decoding layers. """ self.stack(*layers) self.encoding_layes.extend(layers)
[ "Stack", "encoding", "layers", "this", "must", "be", "done", "before", "stacking", "decoding", "layers", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/auto_encoder.py#L41-L46
[ "def", "stack_encoders", "(", "self", ",", "*", "layers", ")", ":", "self", ".", "stack", "(", "*", "layers", ")", "self", ".", "encoding_layes", ".", "extend", "(", "layers", ")" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
AutoEncoder.stack_decoders
Stack decoding layers.
deepy/networks/auto_encoder.py
def stack_decoders(self, *layers): """ Stack decoding layers. """ self.stack(*layers) self.decoding_layers.extend(layers)
def stack_decoders(self, *layers): """ Stack decoding layers. """ self.stack(*layers) self.decoding_layers.extend(layers)
[ "Stack", "decoding", "layers", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/auto_encoder.py#L48-L53
[ "def", "stack_decoders", "(", "self", ",", "*", "layers", ")", ":", "self", ".", "stack", "(", "*", "layers", ")", "self", ".", "decoding_layers", ".", "extend", "(", "layers", ")" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
AutoEncoder.encode
Encode given input.
deepy/networks/auto_encoder.py
def encode(self, x): """ Encode given input. """ if not self.encoding_network: self.encoding_network = NeuralNetwork(self.input_dim, self.input_tensor) self.encoding_network.input_variables = self.input_variables for layer in self.encoding_layes: ...
def encode(self, x): """ Encode given input. """ if not self.encoding_network: self.encoding_network = NeuralNetwork(self.input_dim, self.input_tensor) self.encoding_network.input_variables = self.input_variables for layer in self.encoding_layes: ...
[ "Encode", "given", "input", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/auto_encoder.py#L55-L64
[ "def", "encode", "(", "self", ",", "x", ")", ":", "if", "not", "self", ".", "encoding_network", ":", "self", ".", "encoding_network", "=", "NeuralNetwork", "(", "self", ".", "input_dim", ",", "self", ".", "input_tensor", ")", "self", ".", "encoding_network...
090fbad22a08a809b12951cd0d4984f5bd432698
test
AutoEncoder.decode
Decode given representation.
deepy/networks/auto_encoder.py
def decode(self, x): """ Decode given representation. """ if not self.rep_dim: raise Exception("rep_dim must be set to decode.") if not self.decoding_network: self.decoding_network = NeuralNetwork(self.rep_dim) for layer in self.decoding_layers...
def decode(self, x): """ Decode given representation. """ if not self.rep_dim: raise Exception("rep_dim must be set to decode.") if not self.decoding_network: self.decoding_network = NeuralNetwork(self.rep_dim) for layer in self.decoding_layers...
[ "Decode", "given", "representation", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/auto_encoder.py#L66-L76
[ "def", "decode", "(", "self", ",", "x", ")", ":", "if", "not", "self", ".", "rep_dim", ":", "raise", "Exception", "(", "\"rep_dim must be set to decode.\"", ")", "if", "not", "self", ".", "decoding_network", ":", "self", ".", "decoding_network", "=", "Neural...
090fbad22a08a809b12951cd0d4984f5bd432698
test
create_2d_gaussian
This function creates a 2d gaussian kernel with the standard deviation denoted by sigma :param dim: integer denoting a side (1-d) of gaussian kernel :param sigma: floating point indicating the standard deviation :returns: a numpy 2d array
deepy/preprocessing/elastic_distortion.py
def create_2d_gaussian(dim, sigma): """ This function creates a 2d gaussian kernel with the standard deviation denoted by sigma :param dim: integer denoting a side (1-d) of gaussian kernel :param sigma: floating point indicating the standard deviation :returns: a numpy 2d array """ # ...
def create_2d_gaussian(dim, sigma): """ This function creates a 2d gaussian kernel with the standard deviation denoted by sigma :param dim: integer denoting a side (1-d) of gaussian kernel :param sigma: floating point indicating the standard deviation :returns: a numpy 2d array """ # ...
[ "This", "function", "creates", "a", "2d", "gaussian", "kernel", "with", "the", "standard", "deviation", "denoted", "by", "sigma" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/preprocessing/elastic_distortion.py#L17-L54
[ "def", "create_2d_gaussian", "(", "dim", ",", "sigma", ")", ":", "# check if the dimension is odd", "if", "dim", "%", "2", "==", "0", ":", "raise", "ValueError", "(", "\"Kernel dimension should be odd\"", ")", "# initialize the kernel", "kernel", "=", "np", ".", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
elastic_distortion
This method performs elastic transformations on an image by convolving with a gaussian kernel. :param image: a numpy nd array :kernel_dim: dimension(1-D) of the gaussian kernel :param sigma: standard deviation of the kernel :param alpha: a multiplicative factor for image after convolution :param...
deepy/preprocessing/elastic_distortion.py
def elastic_distortion(image, kernel_dim=21, sigma=6, alpha=30, negated=True): """ This method performs elastic transformations on an image by convolving with a gaussian kernel. :param image: a numpy nd array :kernel_dim: dimension(1-D) of the gaussian kernel :param sigma: standard deviation of ...
def elastic_distortion(image, kernel_dim=21, sigma=6, alpha=30, negated=True): """ This method performs elastic transformations on an image by convolving with a gaussian kernel. :param image: a numpy nd array :kernel_dim: dimension(1-D) of the gaussian kernel :param sigma: standard deviation of ...
[ "This", "method", "performs", "elastic", "transformations", "on", "an", "image", "by", "convolving", "with", "a", "gaussian", "kernel", ".", ":", "param", "image", ":", "a", "numpy", "nd", "array", ":", "kernel_dim", ":", "dimension", "(", "1", "-", "D", ...
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/preprocessing/elastic_distortion.py#L57-L112
[ "def", "elastic_distortion", "(", "image", ",", "kernel_dim", "=", "21", ",", "sigma", "=", "6", ",", "alpha", "=", "30", ",", "negated", "=", "True", ")", ":", "# check if the image is a negated one", "if", "not", "negated", ":", "image", "=", "255", "-",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.stack_layer
Stack a neural layer. :type layer: NeuralLayer :param no_setup: whether the layer is already initialized
deepy/networks/network.py
def stack_layer(self, layer, no_setup=False): """ Stack a neural layer. :type layer: NeuralLayer :param no_setup: whether the layer is already initialized """ if layer.name: layer.name += "%d" % (len(self.layers) + 1) if not self.layers: la...
def stack_layer(self, layer, no_setup=False): """ Stack a neural layer. :type layer: NeuralLayer :param no_setup: whether the layer is already initialized """ if layer.name: layer.name += "%d" % (len(self.layers) + 1) if not self.layers: la...
[ "Stack", "a", "neural", "layer", ".", ":", "type", "layer", ":", "NeuralLayer", ":", "param", "no_setup", ":", "whether", "the", "layer", "is", "already", "initialized" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L79-L95
[ "def", "stack_layer", "(", "self", ",", "layer", ",", "no_setup", "=", "False", ")", ":", "if", "layer", ".", "name", ":", "layer", ".", "name", "+=", "\"%d\"", "%", "(", "len", "(", "self", ".", "layers", ")", "+", "1", ")", "if", "not", "self",...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.register_layer
Register the layer so that it's param will be trained. But the output of the layer will not be stacked.
deepy/networks/network.py
def register_layer(self, layer): """ Register the layer so that it's param will be trained. But the output of the layer will not be stacked. """ if type(layer) == Block: layer.fix() self.parameter_count += layer.parameter_count self.parameters.extend(l...
def register_layer(self, layer): """ Register the layer so that it's param will be trained. But the output of the layer will not be stacked. """ if type(layer) == Block: layer.fix() self.parameter_count += layer.parameter_count self.parameters.extend(l...
[ "Register", "the", "layer", "so", "that", "it", "s", "param", "will", "be", "trained", ".", "But", "the", "output", "of", "the", "layer", "will", "not", "be", "stacked", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L106-L125
[ "def", "register_layer", "(", "self", ",", "layer", ")", ":", "if", "type", "(", "layer", ")", "==", "Block", ":", "layer", ".", "fix", "(", ")", "self", ".", "parameter_count", "+=", "layer", ".", "parameter_count", "self", ".", "parameters", ".", "ex...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.monitor_layer_outputs
Monitoring the outputs of each layer. Useful for troubleshooting convergence problems.
deepy/networks/network.py
def monitor_layer_outputs(self): """ Monitoring the outputs of each layer. Useful for troubleshooting convergence problems. """ for layer, hidden in zip(self.layers, self._hidden_outputs): self.training_monitors.append(('mean(%s)' % (layer.name), abs(hidden).mean()))
def monitor_layer_outputs(self): """ Monitoring the outputs of each layer. Useful for troubleshooting convergence problems. """ for layer, hidden in zip(self.layers, self._hidden_outputs): self.training_monitors.append(('mean(%s)' % (layer.name), abs(hidden).mean()))
[ "Monitoring", "the", "outputs", "of", "each", "layer", ".", "Useful", "for", "troubleshooting", "convergence", "problems", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L147-L153
[ "def", "monitor_layer_outputs", "(", "self", ")", ":", "for", "layer", ",", "hidden", "in", "zip", "(", "self", ".", "layers", ",", "self", ".", "_hidden_outputs", ")", ":", "self", ".", "training_monitors", ".", "append", "(", "(", "'mean(%s)'", "%", "(...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.all_parameters
Return all parameters.
deepy/networks/network.py
def all_parameters(self): """ Return all parameters. """ params = [] params.extend(self.parameters) params.extend(self.free_parameters) return params
def all_parameters(self): """ Return all parameters. """ params = [] params.extend(self.parameters) params.extend(self.free_parameters) return params
[ "Return", "all", "parameters", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L156-L164
[ "def", "all_parameters", "(", "self", ")", ":", "params", "=", "[", "]", "params", ".", "extend", "(", "self", ".", "parameters", ")", "params", ".", "extend", "(", "self", ".", "free_parameters", ")", "return", "params" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.setup_variables
Set up variables.
deepy/networks/network.py
def setup_variables(self): """ Set up variables. """ if self.input_tensor: if type(self.input_tensor) == int: x = dim_to_var(self.input_tensor, name="x") else: x = self.input_tensor else: x = T.matrix('x') ...
def setup_variables(self): """ Set up variables. """ if self.input_tensor: if type(self.input_tensor) == int: x = dim_to_var(self.input_tensor, name="x") else: x = self.input_tensor else: x = T.matrix('x') ...
[ "Set", "up", "variables", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L166-L179
[ "def", "setup_variables", "(", "self", ")", ":", "if", "self", ".", "input_tensor", ":", "if", "type", "(", "self", ".", "input_tensor", ")", "==", "int", ":", "x", "=", "dim_to_var", "(", "self", ".", "input_tensor", ",", "name", "=", "\"x\"", ")", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.compute
Return network output.
deepy/networks/network.py
def compute(self, *x): """ Return network output. """ self._compile() outs = self._compute(*x) if self._output_keys: return MapDict(dict(zip(self._output_keys, outs))) else: return outs
def compute(self, *x): """ Return network output. """ self._compile() outs = self._compute(*x) if self._output_keys: return MapDict(dict(zip(self._output_keys, outs))) else: return outs
[ "Return", "network", "output", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L198-L207
[ "def", "compute", "(", "self", ",", "*", "x", ")", ":", "self", ".", "_compile", "(", ")", "outs", "=", "self", ".", "_compute", "(", "*", "x", ")", "if", "self", ".", "_output_keys", ":", "return", "MapDict", "(", "dict", "(", "zip", "(", "self"...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.save_params
Save parameters to file.
deepy/networks/network.py
def save_params(self, path, new_thread=False): """ Save parameters to file. """ save_logger.info(path) param_variables = self.all_parameters params = [p.get_value().copy() for p in param_variables] if new_thread: thread = Thread(target=save_network_par...
def save_params(self, path, new_thread=False): """ Save parameters to file. """ save_logger.info(path) param_variables = self.all_parameters params = [p.get_value().copy() for p in param_variables] if new_thread: thread = Thread(target=save_network_par...
[ "Save", "parameters", "to", "file", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L237-L249
[ "def", "save_params", "(", "self", ",", "path", ",", "new_thread", "=", "False", ")", ":", "save_logger", ".", "info", "(", "path", ")", "param_variables", "=", "self", ".", "all_parameters", "params", "=", "[", "p", ".", "get_value", "(", ")", ".", "c...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.load_params
Load parameters from file.
deepy/networks/network.py
def load_params(self, path, exclude_free_params=False): """ Load parameters from file. """ if not os.path.exists(path): return; logging.info("loading parameters from %s" % path) # Decide which parameters to load if exclude_free_params: params_to_load =...
def load_params(self, path, exclude_free_params=False): """ Load parameters from file. """ if not os.path.exists(path): return; logging.info("loading parameters from %s" % path) # Decide which parameters to load if exclude_free_params: params_to_load =...
[ "Load", "parameters", "from", "file", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L251-L282
[ "def", "load_params", "(", "self", ",", "path", ",", "exclude_free_params", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "logging", ".", "info", "(", "\"loading parameters from %s\"", "%", "path", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralNetwork.report
Print network statistics.
deepy/networks/network.py
def report(self): """ Print network statistics. """ logging.info("network inputs: %s", " ".join(map(str, self.input_variables))) logging.info("network targets: %s", " ".join(map(str, self.target_variables))) logging.info("network parameters: %s", " ".join(map(str, self.al...
def report(self): """ Print network statistics. """ logging.info("network inputs: %s", " ".join(map(str, self.input_variables))) logging.info("network targets: %s", " ".join(map(str, self.target_variables))) logging.info("network parameters: %s", " ".join(map(str, self.al...
[ "Print", "network", "statistics", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L284-L291
[ "def", "report", "(", "self", ")", ":", "logging", ".", "info", "(", "\"network inputs: %s\"", ",", "\" \"", ".", "join", "(", "map", "(", "str", ",", "self", ".", "input_variables", ")", ")", ")", "logging", ".", "info", "(", "\"network targets: %s\"", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLayer.init
Initialize the layer. :param no_prepare: avoid calling preparation function
deepy/layers/layer.py
def init(self, input_dim=0, input_dims=None, no_prepare=False): """ Initialize the layer. :param no_prepare: avoid calling preparation function """ if self.initialized: return # configure input dimensions if input_dims: self.input_dims = in...
def init(self, input_dim=0, input_dims=None, no_prepare=False): """ Initialize the layer. :param no_prepare: avoid calling preparation function """ if self.initialized: return # configure input dimensions if input_dims: self.input_dims = in...
[ "Initialize", "the", "layer", ".", ":", "param", "no_prepare", ":", "avoid", "calling", "preparation", "function" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/layer.py#L47-L68
[ "def", "init", "(", "self", ",", "input_dim", "=", "0", ",", "input_dims", "=", "None", ",", "no_prepare", "=", "False", ")", ":", "if", "self", ".", "initialized", ":", "return", "# configure input dimensions", "if", "input_dims", ":", "self", ".", "input...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLayer.compute
Compute based on NeuralVariable. :type inputs: list of NeuralVariable :return: NeuralVariable
deepy/layers/layer.py
def compute(self, *inputs, **kwargs): """ Compute based on NeuralVariable. :type inputs: list of NeuralVariable :return: NeuralVariable """ from deepy.core.neural_var import NeuralVariable from deepy.core.graph import graph if type(inputs[0]) != NeuralVar...
def compute(self, *inputs, **kwargs): """ Compute based on NeuralVariable. :type inputs: list of NeuralVariable :return: NeuralVariable """ from deepy.core.neural_var import NeuralVariable from deepy.core.graph import graph if type(inputs[0]) != NeuralVar...
[ "Compute", "based", "on", "NeuralVariable", ".", ":", "type", "inputs", ":", "list", "of", "NeuralVariable", ":", "return", ":", "NeuralVariable" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/layer.py#L70-L97
[ "def", "compute", "(", "self", ",", "*", "inputs", ",", "*", "*", "kwargs", ")", ":", "from", "deepy", ".", "core", ".", "neural_var", "import", "NeuralVariable", "from", "deepy", ".", "core", ".", "graph", "import", "graph", "if", "type", "(", "inputs...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLayer.belongs_to
Let the given block or network manage the parameters of this layer. :param block: Block or NeuralNetwork :return: NeuralLayer
deepy/layers/layer.py
def belongs_to(self, block): """ Let the given block or network manage the parameters of this layer. :param block: Block or NeuralNetwork :return: NeuralLayer """ if self._linked_block: raise SystemError("The layer {} has already blonged to {}".format(self.nam...
def belongs_to(self, block): """ Let the given block or network manage the parameters of this layer. :param block: Block or NeuralNetwork :return: NeuralLayer """ if self._linked_block: raise SystemError("The layer {} has already blonged to {}".format(self.nam...
[ "Let", "the", "given", "block", "or", "network", "manage", "the", "parameters", "of", "this", "layer", ".", ":", "param", "block", ":", "Block", "or", "NeuralNetwork", ":", "return", ":", "NeuralLayer" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/layer.py#L111-L121
[ "def", "belongs_to", "(", "self", ",", "block", ")", ":", "if", "self", ".", "_linked_block", ":", "raise", "SystemError", "(", "\"The layer {} has already blonged to {}\"", ".", "format", "(", "self", ".", "name", ",", "self", ".", "_linked_block", ".", "name...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLayer.register_parameters
Register parameters.
deepy/layers/layer.py
def register_parameters(self, *parameters): """ Register parameters. """ for param in parameters: self.parameter_count += np.prod(param.get_value().shape) self.parameters.extend(parameters)
def register_parameters(self, *parameters): """ Register parameters. """ for param in parameters: self.parameter_count += np.prod(param.get_value().shape) self.parameters.extend(parameters)
[ "Register", "parameters", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/layer.py#L137-L143
[ "def", "register_parameters", "(", "self", ",", "*", "parameters", ")", ":", "for", "param", "in", "parameters", ":", "self", ".", "parameter_count", "+=", "np", ".", "prod", "(", "param", ".", "get_value", "(", ")", ".", "shape", ")", "self", ".", "pa...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLayer.register_updates
Register updates that will be executed in each iteration.
deepy/layers/layer.py
def register_updates(self, *updates): """ Register updates that will be executed in each iteration. """ for key, node in updates: if key not in self._registered_updates: self.updates.append((key, node)) self._registered_updates.add(key)
def register_updates(self, *updates): """ Register updates that will be executed in each iteration. """ for key, node in updates: if key not in self._registered_updates: self.updates.append((key, node)) self._registered_updates.add(key)
[ "Register", "updates", "that", "will", "be", "executed", "in", "each", "iteration", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/layer.py#L151-L158
[ "def", "register_updates", "(", "self", ",", "*", "updates", ")", ":", "for", "key", ",", "node", "in", "updates", ":", "if", "key", "not", "in", "self", ".", "_registered_updates", ":", "self", ".", "updates", ".", "append", "(", "(", "key", ",", "n...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLayer.register_training_updates
Register updates that will only be executed in training phase.
deepy/layers/layer.py
def register_training_updates(self, *updates): """ Register updates that will only be executed in training phase. """ for key, node in updates: if key not in self._registered_training_updates: self.training_updates.append((key, node)) self._reg...
def register_training_updates(self, *updates): """ Register updates that will only be executed in training phase. """ for key, node in updates: if key not in self._registered_training_updates: self.training_updates.append((key, node)) self._reg...
[ "Register", "updates", "that", "will", "only", "be", "executed", "in", "training", "phase", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/layer.py#L160-L167
[ "def", "register_training_updates", "(", "self", ",", "*", "updates", ")", ":", "for", "key", ",", "node", "in", "updates", ":", "if", "key", "not", "in", "self", ".", "_registered_training_updates", ":", "self", ".", "training_updates", ".", "append", "(", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
NeuralLayer.register_monitors
Register monitors they should be tuple of name and Theano variable.
deepy/layers/layer.py
def register_monitors(self, *monitors): """ Register monitors they should be tuple of name and Theano variable. """ for key, node in monitors: if key not in self._registered_monitors: node *= 1.0 # Avoid CudaNdarray self.training_monitors.appen...
def register_monitors(self, *monitors): """ Register monitors they should be tuple of name and Theano variable. """ for key, node in monitors: if key not in self._registered_monitors: node *= 1.0 # Avoid CudaNdarray self.training_monitors.appen...
[ "Register", "monitors", "they", "should", "be", "tuple", "of", "name", "and", "Theano", "variable", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/layer.py#L169-L178
[ "def", "register_monitors", "(", "self", ",", "*", "monitors", ")", ":", "for", "key", ",", "node", "in", "monitors", ":", "if", "key", "not", "in", "self", ".", "_registered_monitors", ":", "node", "*=", "1.0", "# Avoid CudaNdarray", "self", ".", "trainin...
090fbad22a08a809b12951cd0d4984f5bd432698
test
multiple_l2_norm
Get the L2 norm of multiple tensors. This function is taken from blocks.
deepy/trainers/util.py
def multiple_l2_norm(tensors): """ Get the L2 norm of multiple tensors. This function is taken from blocks. """ # Another way for doing this, I don't know which one is fast # return T.sqrt(sum(T.sum(t ** 2) for t in tensors)) flattened = [T.as_tensor_variable(t).flatten() for t in tensors] ...
def multiple_l2_norm(tensors): """ Get the L2 norm of multiple tensors. This function is taken from blocks. """ # Another way for doing this, I don't know which one is fast # return T.sqrt(sum(T.sum(t ** 2) for t in tensors)) flattened = [T.as_tensor_variable(t).flatten() for t in tensors] ...
[ "Get", "the", "L2", "norm", "of", "multiple", "tensors", ".", "This", "function", "is", "taken", "from", "blocks", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/util.py#L19-L30
[ "def", "multiple_l2_norm", "(", "tensors", ")", ":", "# Another way for doing this, I don't know which one is fast", "# return T.sqrt(sum(T.sum(t ** 2) for t in tensors))", "flattened", "=", "[", "T", ".", "as_tensor_variable", "(", "t", ")", ".", "flatten", "(", ")", "for"...
090fbad22a08a809b12951cd0d4984f5bd432698
test
StreamPickler.dump_one
dumps one element to file_obj, a file opened in write mode
deepy/utils/stream_pickler.py
def dump_one(elt_to_pickle, file_obj): """ dumps one element to file_obj, a file opened in write mode """ pickled_elt_str = dumps(elt_to_pickle) file_obj.write(pickled_elt_str) # record separator is a blank line # (since pickled_elt_str might contain its own newli...
def dump_one(elt_to_pickle, file_obj): """ dumps one element to file_obj, a file opened in write mode """ pickled_elt_str = dumps(elt_to_pickle) file_obj.write(pickled_elt_str) # record separator is a blank line # (since pickled_elt_str might contain its own newli...
[ "dumps", "one", "element", "to", "file_obj", "a", "file", "opened", "in", "write", "mode" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/utils/stream_pickler.py#L25-L33
[ "def", "dump_one", "(", "elt_to_pickle", ",", "file_obj", ")", ":", "pickled_elt_str", "=", "dumps", "(", "elt_to_pickle", ")", "file_obj", ".", "write", "(", "pickled_elt_str", ")", "# record separator is a blank line", "# (since pickled_elt_str might contain its own newli...
090fbad22a08a809b12951cd0d4984f5bd432698
test
StreamPickler.load
load contents from file_obj, returning a generator that yields one element at a time
deepy/utils/stream_pickler.py
def load(file_obj): """ load contents from file_obj, returning a generator that yields one element at a time """ cur_elt = [] for line in file_obj: cur_elt.append(line) if line == '\n': pickled_elt_str = ''.join(cur_elt) cur_el...
def load(file_obj): """ load contents from file_obj, returning a generator that yields one element at a time """ cur_elt = [] for line in file_obj: cur_elt.append(line) if line == '\n': pickled_elt_str = ''.join(cur_elt) cur_el...
[ "load", "contents", "from", "file_obj", "returning", "a", "generator", "that", "yields", "one", "element", "at", "a", "time" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/utils/stream_pickler.py#L36-L53
[ "def", "load", "(", "file_obj", ")", ":", "cur_elt", "=", "[", "]", "for", "line", "in", "file_obj", ":", "cur_elt", ".", "append", "(", "line", ")", "if", "line", "==", "'\\n'", ":", "pickled_elt_str", "=", "''", ".", "join", "(", "cur_elt", ")", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Block.fix
Fix the block, register all the parameters of sub layers. :return:
deepy/layers/block.py
def fix(self): """ Fix the block, register all the parameters of sub layers. :return: """ if not self.fixed: for layer in self.layers: if not layer.initialized: raise Exception("All sub layers in a block must be initialized when fix...
def fix(self): """ Fix the block, register all the parameters of sub layers. :return: """ if not self.fixed: for layer in self.layers: if not layer.initialized: raise Exception("All sub layers in a block must be initialized when fix...
[ "Fix", "the", "block", "register", "all", "the", "parameters", "of", "sub", "layers", ".", ":", "return", ":" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/block.py#L24-L34
[ "def", "fix", "(", "self", ")", ":", "if", "not", "self", ".", "fixed", ":", "for", "layer", "in", "self", ".", "layers", ":", "if", "not", "layer", ".", "initialized", ":", "raise", "Exception", "(", "\"All sub layers in a block must be initialized when fixin...
090fbad22a08a809b12951cd0d4984f5bd432698
test
Block.register_layer
Register one connected layer. :type layer: NeuralLayer
deepy/layers/block.py
def register_layer(self, layer): """ Register one connected layer. :type layer: NeuralLayer """ if self.fixed: raise Exception("After a block is fixed, no more layers can be registered.") self.layers.append(layer)
def register_layer(self, layer): """ Register one connected layer. :type layer: NeuralLayer """ if self.fixed: raise Exception("After a block is fixed, no more layers can be registered.") self.layers.append(layer)
[ "Register", "one", "connected", "layer", ".", ":", "type", "layer", ":", "NeuralLayer" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/block.py#L51-L58
[ "def", "register_layer", "(", "self", ",", "layer", ")", ":", "if", "self", ".", "fixed", ":", "raise", "Exception", "(", "\"After a block is fixed, no more layers can be registered.\"", ")", "self", ".", "layers", ".", "append", "(", "layer", ")" ]
090fbad22a08a809b12951cd0d4984f5bd432698
test
Block.load_params
Load parameters to the block.
deepy/layers/block.py
def load_params(self, path, exclude_free_params=False): from deepy.core import graph """ Load parameters to the block. """ from deepy.core.comp_graph import ComputationalGraph model = graph.compile(blocks=[self]) model.load_params(path, exclude_free_params=exclude...
def load_params(self, path, exclude_free_params=False): from deepy.core import graph """ Load parameters to the block. """ from deepy.core.comp_graph import ComputationalGraph model = graph.compile(blocks=[self]) model.load_params(path, exclude_free_params=exclude...
[ "Load", "parameters", "to", "the", "block", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/block.py#L64-L71
[ "def", "load_params", "(", "self", ",", "path", ",", "exclude_free_params", "=", "False", ")", ":", "from", "deepy", ".", "core", "import", "graph", "from", "deepy", ".", "core", ".", "comp_graph", "import", "ComputationalGraph", "model", "=", "graph", ".", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
RecurrentLayer.compute_step
Compute one step in the RNN. :return: one variable for RNN and GRU, multiple variables for LSTM
deepy/layers/recurrent.py
def compute_step(self, state, lstm_cell=None, input=None, additional_inputs=None): """ Compute one step in the RNN. :return: one variable for RNN and GRU, multiple variables for LSTM """ if not self.initialized: input_dim = None if input and hasattr(input....
def compute_step(self, state, lstm_cell=None, input=None, additional_inputs=None): """ Compute one step in the RNN. :return: one variable for RNN and GRU, multiple variables for LSTM """ if not self.initialized: input_dim = None if input and hasattr(input....
[ "Compute", "one", "step", "in", "the", "RNN", ".", ":", "return", ":", "one", "variable", "for", "RNN", "and", "GRU", "multiple", "variables", "for", "LSTM" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/recurrent.py#L85-L106
[ "def", "compute_step", "(", "self", ",", "state", ",", "lstm_cell", "=", "None", ",", "input", "=", "None", ",", "additional_inputs", "=", "None", ")", ":", "if", "not", "self", ".", "initialized", ":", "input_dim", "=", "None", "if", "input", "and", "...
090fbad22a08a809b12951cd0d4984f5bd432698
test
RecurrentLayer.get_initial_states
:type input_var: T.var :rtype: dict
deepy/layers/recurrent.py
def get_initial_states(self, input_var, init_state=None): """ :type input_var: T.var :rtype: dict """ initial_states = {} for state in self.state_names: if state != "state" or not init_state: if self._input_type == 'sequence' and input_var.ndim...
def get_initial_states(self, input_var, init_state=None): """ :type input_var: T.var :rtype: dict """ initial_states = {} for state in self.state_names: if state != "state" or not init_state: if self._input_type == 'sequence' and input_var.ndim...
[ ":", "type", "input_var", ":", "T", ".", "var", ":", "rtype", ":", "dict" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/recurrent.py#L109-L122
[ "def", "get_initial_states", "(", "self", ",", "input_var", ",", "init_state", "=", "None", ")", ":", "initial_states", "=", "{", "}", "for", "state", "in", "self", ".", "state_names", ":", "if", "state", "!=", "\"state\"", "or", "not", "init_state", ":", ...
090fbad22a08a809b12951cd0d4984f5bd432698
test
RecurrentLayer.get_step_inputs
:type input_var: T.var :rtype: dict
deepy/layers/recurrent.py
def get_step_inputs(self, input_var, states=None, mask=None, additional_inputs=None): """ :type input_var: T.var :rtype: dict """ step_inputs = {} if self._input_type == "sequence": if not additional_inputs: additional_inputs = [] i...
def get_step_inputs(self, input_var, states=None, mask=None, additional_inputs=None): """ :type input_var: T.var :rtype: dict """ step_inputs = {} if self._input_type == "sequence": if not additional_inputs: additional_inputs = [] i...
[ ":", "type", "input_var", ":", "T", ".", "var", ":", "rtype", ":", "dict" ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/recurrent.py#L125-L145
[ "def", "get_step_inputs", "(", "self", ",", "input_var", ",", "states", "=", "None", ",", "mask", "=", "None", ",", "additional_inputs", "=", "None", ")", ":", "step_inputs", "=", "{", "}", "if", "self", ".", "_input_type", "==", "\"sequence\"", ":", "if...
090fbad22a08a809b12951cd0d4984f5bd432698