repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | highway_core_with_recurrent_dropout | def highway_core_with_recurrent_dropout(
hidden_size,
num_layers,
keep_prob=0.5,
**kwargs):
"""Highway core with recurrent dropout.
Args:
hidden_size: (int) Hidden size dimensionality.
num_layers: (int) Number of highway layers.
keep_prob: the probability to keep an entry when applying ... | python | def highway_core_with_recurrent_dropout(
hidden_size,
num_layers,
keep_prob=0.5,
**kwargs):
"""Highway core with recurrent dropout.
Args:
hidden_size: (int) Hidden size dimensionality.
num_layers: (int) Number of highway layers.
keep_prob: the probability to keep an entry when applying ... | [
"def",
"highway_core_with_recurrent_dropout",
"(",
"hidden_size",
",",
"num_layers",
",",
"keep_prob",
"=",
"0.5",
",",
"*",
"*",
"kwargs",
")",
":",
"core",
"=",
"HighwayCore",
"(",
"hidden_size",
",",
"num_layers",
",",
"*",
"*",
"kwargs",
")",
"return",
"... | Highway core with recurrent dropout.
Args:
hidden_size: (int) Hidden size dimensionality.
num_layers: (int) Number of highway layers.
keep_prob: the probability to keep an entry when applying dropout.
**kwargs: Extra keyword arguments to pass to the highway core.
Returns:
A tuple (train_core, ... | [
"Highway",
"core",
"with",
"recurrent",
"dropout",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1748-L1768 | train | Highway core with recurrent dropout. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | LSTM.get_possible_initializer_keys | def get_possible_initializer_keys(cls, use_peepholes=False,
use_projection=False):
"""Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
w_gates: weight for gates
b_gates: bias of gates
w_f_... | python | def get_possible_initializer_keys(cls, use_peepholes=False,
use_projection=False):
"""Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
w_gates: weight for gates
b_gates: bias of gates
w_f_... | [
"def",
"get_possible_initializer_keys",
"(",
"cls",
",",
"use_peepholes",
"=",
"False",
",",
"use_projection",
"=",
"False",
")",
":",
"possible_keys",
"=",
"cls",
".",
"POSSIBLE_INITIALIZER_KEYS",
".",
"copy",
"(",
")",
"if",
"not",
"use_peepholes",
":",
"possi... | Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
w_gates: weight for gates
b_gates: bias of gates
w_f_diag: weight for prev_cell -> forget gate peephole
w_i_diag: weight for prev_cell -> input gate peephole
w_o_diag:... | [
"Returns",
"the",
"keys",
"the",
"dictionary",
"of",
"variable",
"initializers",
"may",
"contain",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L178-L207 | train | Returns the set of possible variable initializers that may be used for the given class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | LSTM._build | def _build(self, inputs, prev_state):
"""Connects the LSTM module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing variables to be the correct size for
the... | python | def _build(self, inputs, prev_state):
"""Connects the LSTM module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing variables to be the correct size for
the... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"prev_state",
")",
":",
"prev_hidden",
",",
"prev_cell",
"=",
"prev_state",
"# pylint: disable=invalid-unary-operand-type",
"if",
"self",
".",
"_hidden_clip_value",
"is",
"not",
"None",
":",
"prev_hidden",
"=",
"tf... | Connects the LSTM module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing variables to be the correct size for
their corresponding multiplications. The batch s... | [
"Connects",
"the",
"LSTM",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L209-L276 | train | Connects the LSTM module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | LSTM._create_gate_variables | def _create_gate_variables(self, input_shape, dtype):
"""Initialize the variables used for the gates."""
if len(input_shape) != 2:
raise ValueError(
"Rank of shape must be {} not: {}".format(2, len(input_shape)))
equiv_input_size = self._hidden_state_size + input_shape.dims[1].value
ini... | python | def _create_gate_variables(self, input_shape, dtype):
"""Initialize the variables used for the gates."""
if len(input_shape) != 2:
raise ValueError(
"Rank of shape must be {} not: {}".format(2, len(input_shape)))
equiv_input_size = self._hidden_state_size + input_shape.dims[1].value
ini... | [
"def",
"_create_gate_variables",
"(",
"self",
",",
"input_shape",
",",
"dtype",
")",
":",
"if",
"len",
"(",
"input_shape",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"Rank of shape must be {} not: {}\"",
".",
"format",
"(",
"2",
",",
"len",
"(",
"inp... | Initialize the variables used for the gates. | [
"Initialize",
"the",
"variables",
"used",
"for",
"the",
"gates",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L278-L310 | train | Initialize the variables used for the gates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | LSTM._create_peephole_variables | def _create_peephole_variables(self, dtype):
"""Initialize the variables used for the peephole connections."""
self._w_f_diag = tf.get_variable(
self.W_F_DIAG,
shape=[self._hidden_size],
dtype=dtype,
initializer=self._initializers.get(self.W_F_DIAG),
partitioner=self._par... | python | def _create_peephole_variables(self, dtype):
"""Initialize the variables used for the peephole connections."""
self._w_f_diag = tf.get_variable(
self.W_F_DIAG,
shape=[self._hidden_size],
dtype=dtype,
initializer=self._initializers.get(self.W_F_DIAG),
partitioner=self._par... | [
"def",
"_create_peephole_variables",
"(",
"self",
",",
"dtype",
")",
":",
"self",
".",
"_w_f_diag",
"=",
"tf",
".",
"get_variable",
"(",
"self",
".",
"W_F_DIAG",
",",
"shape",
"=",
"[",
"self",
".",
"_hidden_size",
"]",
",",
"dtype",
"=",
"dtype",
",",
... | Initialize the variables used for the peephole connections. | [
"Initialize",
"the",
"variables",
"used",
"for",
"the",
"peephole",
"connections",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L312-L334 | train | Initialize the variables used for the peephole connections. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | LSTM.state_size | def state_size(self):
"""Tuple of `tf.TensorShape`s indicating the size of state tensors."""
return LSTMState(tf.TensorShape([self._hidden_state_size]),
tf.TensorShape([self._hidden_size])) | python | def state_size(self):
"""Tuple of `tf.TensorShape`s indicating the size of state tensors."""
return LSTMState(tf.TensorShape([self._hidden_state_size]),
tf.TensorShape([self._hidden_size])) | [
"def",
"state_size",
"(",
"self",
")",
":",
"return",
"LSTMState",
"(",
"tf",
".",
"TensorShape",
"(",
"[",
"self",
".",
"_hidden_state_size",
"]",
")",
",",
"tf",
".",
"TensorShape",
"(",
"[",
"self",
".",
"_hidden_size",
"]",
")",
")"
] | Tuple of `tf.TensorShape`s indicating the size of state tensors. | [
"Tuple",
"of",
"tf",
".",
"TensorShape",
"s",
"indicating",
"the",
"size",
"of",
"state",
"tensors",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L337-L340 | train | Tuple of tf. TensorShape s indicating the size of state tensors. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | RecurrentDropoutWrapper.initial_state | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state tensor of zeros."""
core_initial_state = self._core.initial_state(
batch_size, dtype=dtyp... | python | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state tensor of zeros."""
core_initial_state = self._core.initial_state(
batch_size, dtype=dtyp... | [
"def",
"initial_state",
"(",
"self",
",",
"batch_size",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
"trainable",
"=",
"False",
",",
"trainable_initializers",
"=",
"None",
",",
"trainable_regularizers",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"co... | Builds the default start state tensor of zeros. | [
"Builds",
"the",
"default",
"start",
"state",
"tensor",
"of",
"zeros",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L404-L422 | train | Builds the default start state tensor of zeros. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | ZoneoutWrapper.initial_state | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state tensor of zeros."""
return self._core.initial_state(
batch_size, dtype=dtype, trainable=t... | python | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state tensor of zeros."""
return self._core.initial_state(
batch_size, dtype=dtype, trainable=t... | [
"def",
"initial_state",
"(",
"self",
",",
"batch_size",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
"trainable",
"=",
"False",
",",
"trainable_initializers",
"=",
"None",
",",
"trainable_regularizers",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"re... | Builds the default start state tensor of zeros. | [
"Builds",
"the",
"default",
"start",
"state",
"tensor",
"of",
"zeros",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L501-L508 | train | Builds the default start state tensor of zeros. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | BatchNormLSTM.with_batch_norm_control | def with_batch_norm_control(self, is_training, test_local_stats=True):
"""Wraps this RNNCore with the additional control input to the `BatchNorm`s.
Example usage:
lstm = snt.BatchNormLSTM(4)
is_training = tf.placeholder(tf.bool)
rnn_input = ...
my_rnn = rnn.rnn(lstm.with_batch_norm_con... | python | def with_batch_norm_control(self, is_training, test_local_stats=True):
"""Wraps this RNNCore with the additional control input to the `BatchNorm`s.
Example usage:
lstm = snt.BatchNormLSTM(4)
is_training = tf.placeholder(tf.bool)
rnn_input = ...
my_rnn = rnn.rnn(lstm.with_batch_norm_con... | [
"def",
"with_batch_norm_control",
"(",
"self",
",",
"is_training",
",",
"test_local_stats",
"=",
"True",
")",
":",
"return",
"BatchNormLSTM",
".",
"CoreWithExtraBuildArgs",
"(",
"self",
",",
"is_training",
"=",
"is_training",
",",
"test_local_stats",
"=",
"test_loca... | Wraps this RNNCore with the additional control input to the `BatchNorm`s.
Example usage:
lstm = snt.BatchNormLSTM(4)
is_training = tf.placeholder(tf.bool)
rnn_input = ...
my_rnn = rnn.rnn(lstm.with_batch_norm_control(is_training), rnn_input)
Args:
is_training: Boolean that indic... | [
"Wraps",
"this",
"RNNCore",
"with",
"the",
"additional",
"control",
"input",
"to",
"the",
"BatchNorm",
"s",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L742-L767 | train | Wraps this RNNCore with the additional input to the BatchNorm LSTM. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | BatchNormLSTM.get_possible_initializer_keys | def get_possible_initializer_keys(
cls, use_peepholes=False, use_batch_norm_h=True, use_batch_norm_x=False,
use_batch_norm_c=False):
"""Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
w_gates: weight for gates
b_gates:... | python | def get_possible_initializer_keys(
cls, use_peepholes=False, use_batch_norm_h=True, use_batch_norm_x=False,
use_batch_norm_c=False):
"""Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
w_gates: weight for gates
b_gates:... | [
"def",
"get_possible_initializer_keys",
"(",
"cls",
",",
"use_peepholes",
"=",
"False",
",",
"use_batch_norm_h",
"=",
"True",
",",
"use_batch_norm_x",
"=",
"False",
",",
"use_batch_norm_c",
"=",
"False",
")",
":",
"possible_keys",
"=",
"cls",
".",
"POSSIBLE_INITIA... | Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
w_gates: weight for gates
b_gates: bias of gates
w_f_diag: weight for prev_cell -> forget gate peephole
w_i_diag: weight for prev_cell -> input gate peephole
w_o_diag:... | [
"Returns",
"the",
"keys",
"the",
"dictionary",
"of",
"variable",
"initializers",
"may",
"contain",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L770-L814 | train | Returns the set of possible initialization keys for the given class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | BatchNormLSTM._build | def _build(self, inputs, prev_state, is_training=None, test_local_stats=True):
"""Connects the LSTM module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing var... | python | def _build(self, inputs, prev_state, is_training=None, test_local_stats=True):
"""Connects the LSTM module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing var... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"prev_state",
",",
"is_training",
"=",
"None",
",",
"test_local_stats",
"=",
"True",
")",
":",
"if",
"is_training",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Boolean is_training flag must be explicitly spec... | Connects the LSTM module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing variables to be the correct size for
their corresponding multiplications. The batch s... | [
"Connects",
"the",
"LSTM",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L816-L920 | train | Connects the LSTM module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | BatchNormLSTM._create_batch_norm_variables | def _create_batch_norm_variables(self, dtype):
"""Initialize the variables used for the `BatchNorm`s (if any)."""
# The paper recommends a value of 0.1 for good gradient flow through the
# tanh nonlinearity (although doesn't say whether this is for all gammas,
# or just some).
gamma_initializer = tf... | python | def _create_batch_norm_variables(self, dtype):
"""Initialize the variables used for the `BatchNorm`s (if any)."""
# The paper recommends a value of 0.1 for good gradient flow through the
# tanh nonlinearity (although doesn't say whether this is for all gammas,
# or just some).
gamma_initializer = tf... | [
"def",
"_create_batch_norm_variables",
"(",
"self",
",",
"dtype",
")",
":",
"# The paper recommends a value of 0.1 for good gradient flow through the",
"# tanh nonlinearity (although doesn't say whether this is for all gammas,",
"# or just some).",
"gamma_initializer",
"=",
"tf",
".",
... | Initialize the variables used for the `BatchNorm`s (if any). | [
"Initialize",
"the",
"variables",
"used",
"for",
"the",
"BatchNorm",
"s",
"(",
"if",
"any",
")",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L922-L959 | train | Initialize the variables used for the BatchNorms. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | BatchNormLSTM._create_gate_variables | def _create_gate_variables(self, input_shape, dtype):
"""Initialize the variables used for the gates."""
if len(input_shape) != 2:
raise ValueError(
"Rank of shape must be {} not: {}".format(2, len(input_shape)))
input_size = input_shape.dims[1].value
b_shape = [4 * self._hidden_size]
... | python | def _create_gate_variables(self, input_shape, dtype):
"""Initialize the variables used for the gates."""
if len(input_shape) != 2:
raise ValueError(
"Rank of shape must be {} not: {}".format(2, len(input_shape)))
input_size = input_shape.dims[1].value
b_shape = [4 * self._hidden_size]
... | [
"def",
"_create_gate_variables",
"(",
"self",
",",
"input_shape",
",",
"dtype",
")",
":",
"if",
"len",
"(",
"input_shape",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"Rank of shape must be {} not: {}\"",
".",
"format",
"(",
"2",
",",
"len",
"(",
"inp... | Initialize the variables used for the gates. | [
"Initialize",
"the",
"variables",
"used",
"for",
"the",
"gates",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L961-L1002 | train | Initialize the variables used for the gates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | BatchNormLSTM.initial_state | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state tensor of zeros.
Args:
batch_size: An int, float or scalar Tensor representing the batch s... | python | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state tensor of zeros.
Args:
batch_size: An int, float or scalar Tensor representing the batch s... | [
"def",
"initial_state",
"(",
"self",
",",
"batch_size",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
"trainable",
"=",
"False",
",",
"trainable_initializers",
"=",
"None",
",",
"trainable_regularizers",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if... | Builds the default start state tensor of zeros.
Args:
batch_size: An int, float or scalar Tensor representing the batch size.
dtype: The data type to use for the state.
trainable: Boolean that indicates whether to learn the initial state.
trainable_initializers: An optional pair of initiali... | [
"Builds",
"the",
"default",
"start",
"state",
"tensor",
"of",
"zeros",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1028-L1074 | train | Builds the default start state tensor for the batch norm. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | BatchNormLSTM.state_size | def state_size(self):
"""Tuple of `tf.TensorShape`s indicating the size of state tensors."""
if self._max_unique_stats == 1:
return (tf.TensorShape([self._hidden_size]),
tf.TensorShape([self._hidden_size]))
else:
return (tf.TensorShape([self._hidden_size]),
tf.TensorS... | python | def state_size(self):
"""Tuple of `tf.TensorShape`s indicating the size of state tensors."""
if self._max_unique_stats == 1:
return (tf.TensorShape([self._hidden_size]),
tf.TensorShape([self._hidden_size]))
else:
return (tf.TensorShape([self._hidden_size]),
tf.TensorS... | [
"def",
"state_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"_max_unique_stats",
"==",
"1",
":",
"return",
"(",
"tf",
".",
"TensorShape",
"(",
"[",
"self",
".",
"_hidden_size",
"]",
")",
",",
"tf",
".",
"TensorShape",
"(",
"[",
"self",
".",
"_hidd... | Tuple of `tf.TensorShape`s indicating the size of state tensors. | [
"Tuple",
"of",
"tf",
".",
"TensorShape",
"s",
"indicating",
"the",
"size",
"of",
"state",
"tensors",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1077-L1085 | train | Tuple of tf. TensorShape s indicating the size of state tensors. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | ConvLSTM._new_convolution | def _new_convolution(self, use_bias):
"""Returns new convolution.
Args:
use_bias: Use bias in convolutions. If False, clean_dict removes bias
entries from initializers, partitioners and regularizers passed to
the constructor of the convolution.
"""
def clean_dict(input_dict):
... | python | def _new_convolution(self, use_bias):
"""Returns new convolution.
Args:
use_bias: Use bias in convolutions. If False, clean_dict removes bias
entries from initializers, partitioners and regularizers passed to
the constructor of the convolution.
"""
def clean_dict(input_dict):
... | [
"def",
"_new_convolution",
"(",
"self",
",",
"use_bias",
")",
":",
"def",
"clean_dict",
"(",
"input_dict",
")",
":",
"if",
"input_dict",
"and",
"not",
"use_bias",
":",
"cleaned_dict",
"=",
"input_dict",
".",
"copy",
"(",
")",
"cleaned_dict",
".",
"pop",
"(... | Returns new convolution.
Args:
use_bias: Use bias in convolutions. If False, clean_dict removes bias
entries from initializers, partitioners and regularizers passed to
the constructor of the convolution. | [
"Returns",
"new",
"convolution",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1321-L1345 | train | Returns a new convolution. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | ConvLSTM.state_size | def state_size(self):
"""Tuple of `tf.TensorShape`s indicating the size of state tensors."""
hidden_size = tf.TensorShape(
self._input_shape[:-1] + (self._output_channels,))
return (hidden_size, hidden_size) | python | def state_size(self):
"""Tuple of `tf.TensorShape`s indicating the size of state tensors."""
hidden_size = tf.TensorShape(
self._input_shape[:-1] + (self._output_channels,))
return (hidden_size, hidden_size) | [
"def",
"state_size",
"(",
"self",
")",
":",
"hidden_size",
"=",
"tf",
".",
"TensorShape",
"(",
"self",
".",
"_input_shape",
"[",
":",
"-",
"1",
"]",
"+",
"(",
"self",
".",
"_output_channels",
",",
")",
")",
"return",
"(",
"hidden_size",
",",
"hidden_si... | Tuple of `tf.TensorShape`s indicating the size of state tensors. | [
"Tuple",
"of",
"tf",
".",
"TensorShape",
"s",
"indicating",
"the",
"size",
"of",
"state",
"tensors",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1352-L1356 | train | Tuple of tf. TensorShape s indicating the size of state tensors. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | GRU._build | def _build(self, inputs, prev_state):
"""Connects the GRU module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing variables to be the correct size for
thei... | python | def _build(self, inputs, prev_state):
"""Connects the GRU module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing variables to be the correct size for
thei... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"prev_state",
")",
":",
"input_size",
"=",
"inputs",
".",
"get_shape",
"(",
")",
"[",
"1",
"]",
"weight_shape",
"=",
"(",
"input_size",
",",
"self",
".",
"_hidden_size",
")",
"u_shape",
"=",
"(",
"self"... | Connects the GRU module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as inputs and state must have the same final
dimension, in order for the existing variables to be the correct size for
their corresponding multiplications. The batch si... | [
"Connects",
"the",
"GRU",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1509-L1583 | train | Connects the GRU module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | HighwayCore.get_possible_initializer_keys | def get_possible_initializer_keys(cls, num_layers):
"""Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
wt: weight for input -> T gate
wh: weight for input -> H gate
wtL: weight for prev state -> T gate for layer L (indexed fr... | python | def get_possible_initializer_keys(cls, num_layers):
"""Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
wt: weight for input -> T gate
wh: weight for input -> H gate
wtL: weight for prev state -> T gate for layer L (indexed fr... | [
"def",
"get_possible_initializer_keys",
"(",
"cls",
",",
"num_layers",
")",
":",
"keys",
"=",
"[",
"cls",
".",
"WT",
",",
"cls",
".",
"WH",
"]",
"for",
"layer_index",
"in",
"xrange",
"(",
"num_layers",
")",
":",
"layer_str",
"=",
"str",
"(",
"layer_index... | Returns the keys the dictionary of variable initializers may contain.
The set of all possible initializer keys are:
wt: weight for input -> T gate
wh: weight for input -> H gate
wtL: weight for prev state -> T gate for layer L (indexed from 0)
whL: weight for prev state -> H gate for layer ... | [
"Returns",
"the",
"keys",
"the",
"dictionary",
"of",
"variable",
"initializers",
"may",
"contain",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1661-L1686 | train | Returns the set of possible variable initializers that may be passed to the base class constructor. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/gated_rnn.py | HighwayCore._build | def _build(self, inputs, prev_state):
"""Connects the highway core module into the graph.
Args:
inputs: Tensor of size `[batch_size, input_size]`.
prev_state: Tensor of size `[batch_size, hidden_size]`.
Returns:
A tuple (output, next_state) where `output` is a Tensor of size
`[batc... | python | def _build(self, inputs, prev_state):
"""Connects the highway core module into the graph.
Args:
inputs: Tensor of size `[batch_size, input_size]`.
prev_state: Tensor of size `[batch_size, hidden_size]`.
Returns:
A tuple (output, next_state) where `output` is a Tensor of size
`[batc... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"prev_state",
")",
":",
"input_size",
"=",
"inputs",
".",
"get_shape",
"(",
")",
"[",
"1",
"]",
"weight_shape",
"=",
"(",
"input_size",
",",
"self",
".",
"_hidden_size",
")",
"u_shape",
"=",
"(",
"self"... | Connects the highway core module into the graph.
Args:
inputs: Tensor of size `[batch_size, input_size]`.
prev_state: Tensor of size `[batch_size, hidden_size]`.
Returns:
A tuple (output, next_state) where `output` is a Tensor of size
`[batch_size, hidden_size]` and `next_state` is a T... | [
"Connects",
"the",
"highway",
"core",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/gated_rnn.py#L1688-L1737 | train | Connects the highway core module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | _get_flat_core_sizes | def _get_flat_core_sizes(cores):
"""Obtains the list flattened output sizes of a list of cores.
Args:
cores: list of cores to get the shapes from.
Returns:
List of lists that, for each core, contains the list of its output
dimensions.
"""
core_sizes_lists = []
for core in cores:
flat_out... | python | def _get_flat_core_sizes(cores):
"""Obtains the list flattened output sizes of a list of cores.
Args:
cores: list of cores to get the shapes from.
Returns:
List of lists that, for each core, contains the list of its output
dimensions.
"""
core_sizes_lists = []
for core in cores:
flat_out... | [
"def",
"_get_flat_core_sizes",
"(",
"cores",
")",
":",
"core_sizes_lists",
"=",
"[",
"]",
"for",
"core",
"in",
"cores",
":",
"flat_output_size",
"=",
"nest",
".",
"flatten",
"(",
"core",
".",
"output_size",
")",
"core_sizes_lists",
".",
"append",
"(",
"[",
... | Obtains the list flattened output sizes of a list of cores.
Args:
cores: list of cores to get the shapes from.
Returns:
List of lists that, for each core, contains the list of its output
dimensions. | [
"Obtains",
"the",
"list",
"flattened",
"output",
"sizes",
"of",
"a",
"list",
"of",
"cores",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L39-L54 | train | Gets the list flattened output sizes of a list of cores. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | _get_shape_without_batch_dimension | def _get_shape_without_batch_dimension(tensor_nest):
"""Converts Tensor nest to a TensorShape nest, removing batch dimension."""
def _strip_batch_and_convert_to_shape(tensor):
return tensor.get_shape()[1:]
return nest.map_structure(_strip_batch_and_convert_to_shape, tensor_nest) | python | def _get_shape_without_batch_dimension(tensor_nest):
"""Converts Tensor nest to a TensorShape nest, removing batch dimension."""
def _strip_batch_and_convert_to_shape(tensor):
return tensor.get_shape()[1:]
return nest.map_structure(_strip_batch_and_convert_to_shape, tensor_nest) | [
"def",
"_get_shape_without_batch_dimension",
"(",
"tensor_nest",
")",
":",
"def",
"_strip_batch_and_convert_to_shape",
"(",
"tensor",
")",
":",
"return",
"tensor",
".",
"get_shape",
"(",
")",
"[",
"1",
":",
"]",
"return",
"nest",
".",
"map_structure",
"(",
"_str... | Converts Tensor nest to a TensorShape nest, removing batch dimension. | [
"Converts",
"Tensor",
"nest",
"to",
"a",
"TensorShape",
"nest",
"removing",
"batch",
"dimension",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L57-L61 | train | Converts a Tensor nest to a TensorShape nest removing batch dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | VanillaRNN._build | def _build(self, input_, prev_state):
"""Connects the VanillaRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct size for
... | python | def _build(self, input_, prev_state):
"""Connects the VanillaRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct size for
... | [
"def",
"_build",
"(",
"self",
",",
"input_",
",",
"prev_state",
")",
":",
"self",
".",
"_in_to_hidden_linear",
"=",
"basic",
".",
"Linear",
"(",
"self",
".",
"_hidden_size",
",",
"name",
"=",
"\"in_to_hidden\"",
",",
"initializers",
"=",
"self",
".",
"_ini... | Connects the VanillaRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct size for
their corresponding multiplications. The b... | [
"Connects",
"the",
"VanillaRNN",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L110-L149 | train | Connects the VanillaRNN module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | DeepRNN._check_cores_output_sizes | def _check_cores_output_sizes(self):
"""Checks the output_sizes of the cores of the DeepRNN module.
Raises:
ValueError: if the outputs of the cores cannot be concatenated along their
first dimension.
"""
for core_sizes in zip(*tuple(_get_flat_core_sizes(self._cores))):
first_core_li... | python | def _check_cores_output_sizes(self):
"""Checks the output_sizes of the cores of the DeepRNN module.
Raises:
ValueError: if the outputs of the cores cannot be concatenated along their
first dimension.
"""
for core_sizes in zip(*tuple(_get_flat_core_sizes(self._cores))):
first_core_li... | [
"def",
"_check_cores_output_sizes",
"(",
"self",
")",
":",
"for",
"core_sizes",
"in",
"zip",
"(",
"*",
"tuple",
"(",
"_get_flat_core_sizes",
"(",
"self",
".",
"_cores",
")",
")",
")",
":",
"first_core_list",
"=",
"core_sizes",
"[",
"0",
"]",
"[",
"1",
":... | Checks the output_sizes of the cores of the DeepRNN module.
Raises:
ValueError: if the outputs of the cores cannot be concatenated along their
first dimension. | [
"Checks",
"the",
"output_sizes",
"of",
"the",
"cores",
"of",
"the",
"DeepRNN",
"module",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L294-L309 | train | Checks the output_sizes of the cores of the DeepRNN module. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | DeepRNN._build | def _build(self, inputs, prev_state, **kwargs):
"""Connects the DeepRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct siz... | python | def _build(self, inputs, prev_state, **kwargs):
"""Connects the DeepRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct siz... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"prev_state",
",",
"*",
"*",
"kwargs",
")",
":",
"current_input",
"=",
"inputs",
"next_states",
"=",
"[",
"]",
"outputs",
"=",
"[",
"]",
"recurrent_idx",
"=",
"0",
"concatenate",
"=",
"lambda",
"*",
"ar... | Connects the DeepRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct size for
their corresponding multiplications. The batc... | [
"Connects",
"the",
"DeepRNN",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L311-L370 | train | Connects the DeepRNN module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | DeepRNN.initial_state | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state for a DeepRNN.
Args:
batch_size: An int, float or scalar Tensor representing the batch siz... | python | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state for a DeepRNN.
Args:
batch_size: An int, float or scalar Tensor representing the batch siz... | [
"def",
"initial_state",
"(",
"self",
",",
"batch_size",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
"trainable",
"=",
"False",
",",
"trainable_initializers",
"=",
"None",
",",
"trainable_regularizers",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"in... | Builds the default start state for a DeepRNN.
Args:
batch_size: An int, float or scalar Tensor representing the batch size.
dtype: The data type to use for the state.
trainable: Boolean that indicates whether to learn the initial state.
trainable_initializers: An initializer function or nes... | [
"Builds",
"the",
"default",
"start",
"state",
"for",
"a",
"DeepRNN",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L372-L426 | train | Builds the default start state for a DeepRNN. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | ModelRNN._build | def _build(self, inputs, prev_state):
"""Connects the ModelRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct size for
... | python | def _build(self, inputs, prev_state):
"""Connects the ModelRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct size for
... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"prev_state",
")",
":",
"next_state",
"=",
"self",
".",
"_model",
"(",
"prev_state",
")",
"# For ModelRNN, the next state of the RNN is the same as the output",
"return",
"next_state",
",",
"next_state"
] | Connects the ModelRNN module into the graph.
If this is not the first time the module has been connected to the graph,
the Tensors provided as input_ and state must have the same final
dimension, in order for the existing variables to be the correct size for
their corresponding multiplications. The bat... | [
"Connects",
"the",
"ModelRNN",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L517-L537 | train | Connects the ModelRNN module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | BidirectionalRNN._build | def _build(self, input_sequence, state):
"""Connects the BidirectionalRNN module into the graph.
Args:
input_sequence: tensor (time, batch, [feature_1, ..]). It must be
time_major.
state: tuple of states for the forward and backward cores.
Returns:
A dict with forward/backard s... | python | def _build(self, input_sequence, state):
"""Connects the BidirectionalRNN module into the graph.
Args:
input_sequence: tensor (time, batch, [feature_1, ..]). It must be
time_major.
state: tuple of states for the forward and backward cores.
Returns:
A dict with forward/backard s... | [
"def",
"_build",
"(",
"self",
",",
"input_sequence",
",",
"state",
")",
":",
"input_shape",
"=",
"input_sequence",
".",
"get_shape",
"(",
")",
"if",
"input_shape",
"[",
"0",
"]",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Time dimension of input (dim 0)... | Connects the BidirectionalRNN module into the graph.
Args:
input_sequence: tensor (time, batch, [feature_1, ..]). It must be
time_major.
state: tuple of states for the forward and backward cores.
Returns:
A dict with forward/backard states and output sequences:
"outputs":{... | [
"Connects",
"the",
"BidirectionalRNN",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L583-L649 | train | Connects the BidirectionalRNN module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/basic_rnn.py | BidirectionalRNN.initial_state | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state for a BidirectionalRNN.
The Bidirectional RNN flattens the states of its forward and backward co... | python | def initial_state(self, batch_size, dtype=tf.float32, trainable=False,
trainable_initializers=None, trainable_regularizers=None,
name=None):
"""Builds the default start state for a BidirectionalRNN.
The Bidirectional RNN flattens the states of its forward and backward co... | [
"def",
"initial_state",
"(",
"self",
",",
"batch_size",
",",
"dtype",
"=",
"tf",
".",
"float32",
",",
"trainable",
"=",
"False",
",",
"trainable_initializers",
"=",
"None",
",",
"trainable_regularizers",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"na... | Builds the default start state for a BidirectionalRNN.
The Bidirectional RNN flattens the states of its forward and backward cores
and concatentates them.
Args:
batch_size: An int, float or scalar Tensor representing the batch size.
dtype: The data type to use for the state.
trainable: B... | [
"Builds",
"the",
"default",
"start",
"state",
"for",
"a",
"BidirectionalRNN",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic_rnn.py#L651-L686 | train | Builds the default start state for a BidirectionalRNN. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/mlp.py | MLP._instantiate_layers | def _instantiate_layers(self):
"""Instantiates all the linear modules used in the network.
Layers are instantiated in the constructor, as opposed to the build
function, because MLP implements the Transposable interface, and the
transpose function can be called before the module is actually connected
... | python | def _instantiate_layers(self):
"""Instantiates all the linear modules used in the network.
Layers are instantiated in the constructor, as opposed to the build
function, because MLP implements the Transposable interface, and the
transpose function can be called before the module is actually connected
... | [
"def",
"_instantiate_layers",
"(",
"self",
")",
":",
"# Here we are entering the module's variable scope to name our submodules",
"# correctly (not to create variables). As such it's safe to not check",
"# whether we're in the same graph. This is important if we're constructing",
"# the module in ... | Instantiates all the linear modules used in the network.
Layers are instantiated in the constructor, as opposed to the build
function, because MLP implements the Transposable interface, and the
transpose function can be called before the module is actually connected
to the graph and build is called.
... | [
"Instantiates",
"all",
"the",
"linear",
"modules",
"used",
"in",
"the",
"network",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/mlp.py#L112-L139 | train | Instantiates all the linear modules used in the network. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/mlp.py | MLP._build | def _build(self, inputs, is_training=True, dropout_keep_prob=0.5):
"""Assembles the `MLP` and connects it to the graph.
Args:
inputs: A 2D Tensor of size `[batch_size, input_size]`.
is_training: A bool or tf.Bool Tensor. Indicates whether we are
currently training. Defaults to `True`.
... | python | def _build(self, inputs, is_training=True, dropout_keep_prob=0.5):
"""Assembles the `MLP` and connects it to the graph.
Args:
inputs: A 2D Tensor of size `[batch_size, input_size]`.
is_training: A bool or tf.Bool Tensor. Indicates whether we are
currently training. Defaults to `True`.
... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"is_training",
"=",
"True",
",",
"dropout_keep_prob",
"=",
"0.5",
")",
":",
"self",
".",
"_input_shape",
"=",
"tuple",
"(",
"inputs",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
")",
"net",
... | Assembles the `MLP` and connects it to the graph.
Args:
inputs: A 2D Tensor of size `[batch_size, input_size]`.
is_training: A bool or tf.Bool Tensor. Indicates whether we are
currently training. Defaults to `True`.
dropout_keep_prob: The probability that each element is kept when
... | [
"Assembles",
"the",
"MLP",
"and",
"connects",
"it",
"to",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/mlp.py#L145-L174 | train | Assembles the MLP and connects it to the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/mlp.py | MLP.output_sizes | def output_sizes(self):
"""Returns a tuple of all output sizes of all the layers."""
return tuple([l() if callable(l) else l for l in self._output_sizes]) | python | def output_sizes(self):
"""Returns a tuple of all output sizes of all the layers."""
return tuple([l() if callable(l) else l for l in self._output_sizes]) | [
"def",
"output_sizes",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"[",
"l",
"(",
")",
"if",
"callable",
"(",
"l",
")",
"else",
"l",
"for",
"l",
"in",
"self",
".",
"_output_sizes",
"]",
")"
] | Returns a tuple of all output sizes of all the layers. | [
"Returns",
"a",
"tuple",
"of",
"all",
"output",
"sizes",
"of",
"all",
"the",
"layers",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/mlp.py#L182-L184 | train | Returns a tuple of all the output sizes of all the layers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/mlp.py | MLP.transpose | def transpose(self, name=None, activate_final=None):
"""Returns transposed `MLP`.
Args:
name: Optional string specifying the name of the transposed module. The
default name is constructed by appending "_transpose"
to `self.module_name`.
activate_final: Optional boolean determining i... | python | def transpose(self, name=None, activate_final=None):
"""Returns transposed `MLP`.
Args:
name: Optional string specifying the name of the transposed module. The
default name is constructed by appending "_transpose"
to `self.module_name`.
activate_final: Optional boolean determining i... | [
"def",
"transpose",
"(",
"self",
",",
"name",
"=",
"None",
",",
"activate_final",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"module_name",
"+",
"\"_transpose\"",
"if",
"activate_final",
"is",
"None",
":",
"activate... | Returns transposed `MLP`.
Args:
name: Optional string specifying the name of the transposed module. The
default name is constructed by appending "_transpose"
to `self.module_name`.
activate_final: Optional boolean determining if the activation and batch
normalization, if turned ... | [
"Returns",
"transposed",
"MLP",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/mlp.py#L237-L265 | train | Returns a new MLP with the same parameters as the current one. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/mlp.py | MLP.clone | def clone(self, name=None):
"""Creates a new MLP with the same structure.
Args:
name: Optional string specifying the name of the new module. The default
name is constructed by appending "_clone" to the original name.
Returns:
A cloned `MLP` module.
"""
if name is None:
n... | python | def clone(self, name=None):
"""Creates a new MLP with the same structure.
Args:
name: Optional string specifying the name of the new module. The default
name is constructed by appending "_clone" to the original name.
Returns:
A cloned `MLP` module.
"""
if name is None:
n... | [
"def",
"clone",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"module_name",
"+",
"\"_clone\"",
"return",
"MLP",
"(",
"name",
"=",
"name",
",",
"output_sizes",
"=",
"self",
".",
"output_si... | Creates a new MLP with the same structure.
Args:
name: Optional string specifying the name of the new module. The default
name is constructed by appending "_clone" to the original name.
Returns:
A cloned `MLP` module. | [
"Creates",
"a",
"new",
"MLP",
"with",
"the",
"same",
"structure",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/mlp.py#L267-L289 | train | Creates a new MLP with the same structure. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/alexnet.py | AlexNet._calc_min_size | def _calc_min_size(self, conv_layers):
"""Calculates the minimum size of the input layer.
Given a set of convolutional layers, calculate the minimum value of
the `input_height` and `input_width`, i.e. such that the output has
size 1x1. Assumes snt.VALID padding.
Args:
conv_layers: List of tu... | python | def _calc_min_size(self, conv_layers):
"""Calculates the minimum size of the input layer.
Given a set of convolutional layers, calculate the minimum value of
the `input_height` and `input_width`, i.e. such that the output has
size 1x1. Assumes snt.VALID padding.
Args:
conv_layers: List of tu... | [
"def",
"_calc_min_size",
"(",
"self",
",",
"conv_layers",
")",
":",
"input_size",
"=",
"1",
"for",
"_",
",",
"conv_params",
",",
"max_pooling",
"in",
"reversed",
"(",
"conv_layers",
")",
":",
"if",
"max_pooling",
"is",
"not",
"None",
":",
"kernel_size",
",... | Calculates the minimum size of the input layer.
Given a set of convolutional layers, calculate the minimum value of
the `input_height` and `input_width`, i.e. such that the output has
size 1x1. Assumes snt.VALID padding.
Args:
conv_layers: List of tuples `(output_channels, (kernel_size, stride),... | [
"Calculates",
"the",
"minimum",
"size",
"of",
"the",
"input",
"layer",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/alexnet.py#L154-L179 | train | Calculates the minimum size of the input layer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/alexnet.py | AlexNet._build | def _build(self, inputs, keep_prob=None, is_training=None,
test_local_stats=True):
"""Connects the AlexNet module into the graph.
The is_training flag only controls the batch norm settings, if `False` it
does not force no dropout by overriding any input `keep_prob`. To avoid any
confusion ... | python | def _build(self, inputs, keep_prob=None, is_training=None,
test_local_stats=True):
"""Connects the AlexNet module into the graph.
The is_training flag only controls the batch norm settings, if `False` it
does not force no dropout by overriding any input `keep_prob`. To avoid any
confusion ... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"keep_prob",
"=",
"None",
",",
"is_training",
"=",
"None",
",",
"test_local_stats",
"=",
"True",
")",
":",
"# Check input shape",
"if",
"(",
"self",
".",
"_use_batch_norm",
"or",
"keep_prob",
"is",
"not",
"... | Connects the AlexNet module into the graph.
The is_training flag only controls the batch norm settings, if `False` it
does not force no dropout by overriding any input `keep_prob`. To avoid any
confusion this may cause, if `is_training=False` and `keep_prob` would cause
dropout to be applied, an error ... | [
"Connects",
"the",
"AlexNet",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/alexnet.py#L181-L291 | train | Connects the AlexNet module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/dataset_nth_farthest.py | NthFarthest._get_single_set | def _get_single_set(self, num_objects, num_features):
"""Generate one input sequence and output label.
Each sequences of objects has a feature that consists of the feature vector
for that object plus the encoding for its ID, the reference vector ID and
the n-th value relative ID for a total feature siz... | python | def _get_single_set(self, num_objects, num_features):
"""Generate one input sequence and output label.
Each sequences of objects has a feature that consists of the feature vector
for that object plus the encoding for its ID, the reference vector ID and
the n-th value relative ID for a total feature siz... | [
"def",
"_get_single_set",
"(",
"self",
",",
"num_objects",
",",
"num_features",
")",
":",
"# Generate random binary vectors",
"data",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"1",
",",
"1",
",",
"size",
"=",
"(",
"num_objects",
",",
"num_features"... | Generate one input sequence and output label.
Each sequences of objects has a feature that consists of the feature vector
for that object plus the encoding for its ID, the reference vector ID and
the n-th value relative ID for a total feature size of:
`num_objects` * 3 + `num_features`
Args:
... | [
"Generate",
"one",
"input",
"sequence",
"and",
"output",
"label",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/dataset_nth_farthest.py#L51-L97 | train | Generate one input sequence and output label. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/dataset_nth_farthest.py | NthFarthest._get_batch_data | def _get_batch_data(self, batch_size, num_objects, num_features):
"""Assembles a batch of input tensors and output labels.
Args:
batch_size: int. number of sequence batches.
num_objects: int. number of objects in the sequence.
num_features: int. feature size of each object.
Returns:
... | python | def _get_batch_data(self, batch_size, num_objects, num_features):
"""Assembles a batch of input tensors and output labels.
Args:
batch_size: int. number of sequence batches.
num_objects: int. number of objects in the sequence.
num_features: int. feature size of each object.
Returns:
... | [
"def",
"_get_batch_data",
"(",
"self",
",",
"batch_size",
",",
"num_objects",
",",
"num_features",
")",
":",
"all_inputs",
"=",
"[",
"]",
"all_labels",
"=",
"[",
"]",
"for",
"_",
"in",
"six",
".",
"moves",
".",
"range",
"(",
"batch_size",
")",
":",
"in... | Assembles a batch of input tensors and output labels.
Args:
batch_size: int. number of sequence batches.
num_objects: int. number of objects in the sequence.
num_features: int. feature size of each object.
Returns:
1. np.ndarray (`batch_size`, `num_objects`,
(`num_... | [
"Assembles",
"a",
"batch",
"of",
"input",
"tensors",
"and",
"output",
"labels",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/dataset_nth_farthest.py#L99-L120 | train | Assembles a batch of input tensors and output labels. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/dataset_nth_farthest.py | NthFarthest.get_batch | def get_batch(self):
"""Returns set of nth-farthest input tensors and labels.
Returns:
1. tf.Tensor (`batch_size`, `num_objects`,
(`num_features` + 3 * `num_objects`)).
2. tf.Tensor (`batch_size`). Output object reference label.
"""
params = [self._batch_size, self._num... | python | def get_batch(self):
"""Returns set of nth-farthest input tensors and labels.
Returns:
1. tf.Tensor (`batch_size`, `num_objects`,
(`num_features` + 3 * `num_objects`)).
2. tf.Tensor (`batch_size`). Output object reference label.
"""
params = [self._batch_size, self._num... | [
"def",
"get_batch",
"(",
"self",
")",
":",
"params",
"=",
"[",
"self",
".",
"_batch_size",
",",
"self",
".",
"_num_objects",
",",
"self",
".",
"_num_features",
"]",
"inputs",
",",
"labels",
"=",
"tf",
".",
"py_func",
"(",
"self",
".",
"_get_batch_data",
... | Returns set of nth-farthest input tensors and labels.
Returns:
1. tf.Tensor (`batch_size`, `num_objects`,
(`num_features` + 3 * `num_objects`)).
2. tf.Tensor (`batch_size`). Output object reference label. | [
"Returns",
"set",
"of",
"nth",
"-",
"farthest",
"input",
"tensors",
"and",
"labels",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/dataset_nth_farthest.py#L122-L136 | train | Returns set of nth - farthest input tensors and labels. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _default_transpose_size | def _default_transpose_size(input_shape, stride, kernel_shape=None,
padding=SAME):
"""Returns default (maximal) output shape for a transpose convolution.
In general, there are multiple possible output shapes that a transpose
convolution with a given `input_shape` can map to. This func... | python | def _default_transpose_size(input_shape, stride, kernel_shape=None,
padding=SAME):
"""Returns default (maximal) output shape for a transpose convolution.
In general, there are multiple possible output shapes that a transpose
convolution with a given `input_shape` can map to. This func... | [
"def",
"_default_transpose_size",
"(",
"input_shape",
",",
"stride",
",",
"kernel_shape",
"=",
"None",
",",
"padding",
"=",
"SAME",
")",
":",
"if",
"not",
"input_shape",
":",
"raise",
"TypeError",
"(",
"\"input_shape is None; if using Sonnet, are you sure you \"",
"\"... | Returns default (maximal) output shape for a transpose convolution.
In general, there are multiple possible output shapes that a transpose
convolution with a given `input_shape` can map to. This function returns the
output shape which evenly divides the stride to produce the input shape in
a forward convolutio... | [
"Returns",
"default",
"(",
"maximal",
")",
"output",
"shape",
"for",
"a",
"transpose",
"convolution",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L63-L107 | train | Returns the default output shape for a transpose convolution. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _fill_shape | def _fill_shape(x, n):
"""Converts a dimension to a tuple of dimensions of a given size.
This is used to allow shorthand notation for various configuration parameters.
A user can provide either, for example, `2` or `[2, 2]` as a kernel shape, and
this function returns `(2, 2)` in both cases. Passing `[1, 2]` w... | python | def _fill_shape(x, n):
"""Converts a dimension to a tuple of dimensions of a given size.
This is used to allow shorthand notation for various configuration parameters.
A user can provide either, for example, `2` or `[2, 2]` as a kernel shape, and
this function returns `(2, 2)` in both cases. Passing `[1, 2]` w... | [
"def",
"_fill_shape",
"(",
"x",
",",
"n",
")",
":",
"if",
"not",
"isinstance",
"(",
"n",
",",
"numbers",
".",
"Integral",
")",
"or",
"n",
"<",
"1",
":",
"raise",
"TypeError",
"(",
"\"n must be a positive integer\"",
")",
"if",
"(",
"isinstance",
"(",
"... | Converts a dimension to a tuple of dimensions of a given size.
This is used to allow shorthand notation for various configuration parameters.
A user can provide either, for example, `2` or `[2, 2]` as a kernel shape, and
this function returns `(2, 2)` in both cases. Passing `[1, 2]` will return
`(1, 2)`.
Ar... | [
"Converts",
"a",
"dimension",
"to",
"a",
"tuple",
"of",
"dimensions",
"of",
"a",
"given",
"size",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L110-L145 | train | Converts a dimension to a tuple of dimensions of a given size. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _fill_and_verify_parameter_shape | def _fill_and_verify_parameter_shape(x, n, parameter_label):
"""Expands x if necessary into a `n`-D kernel shape and reports errors."""
try:
return _fill_shape(x, n)
except TypeError as e:
raise base.IncompatibleShapeError("Invalid " + parameter_label + " shape: "
"{}... | python | def _fill_and_verify_parameter_shape(x, n, parameter_label):
"""Expands x if necessary into a `n`-D kernel shape and reports errors."""
try:
return _fill_shape(x, n)
except TypeError as e:
raise base.IncompatibleShapeError("Invalid " + parameter_label + " shape: "
"{}... | [
"def",
"_fill_and_verify_parameter_shape",
"(",
"x",
",",
"n",
",",
"parameter_label",
")",
":",
"try",
":",
"return",
"_fill_shape",
"(",
"x",
",",
"n",
")",
"except",
"TypeError",
"as",
"e",
":",
"raise",
"base",
".",
"IncompatibleShapeError",
"(",
"\"Inva... | Expands x if necessary into a `n`-D kernel shape and reports errors. | [
"Expands",
"x",
"if",
"necessary",
"into",
"a",
"n",
"-",
"D",
"kernel",
"shape",
"and",
"reports",
"errors",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L148-L154 | train | Expands x if necessary into a n - D kernel shape and reports errors. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _fill_and_verify_padding | def _fill_and_verify_padding(padding, n):
"""Verifies that the provided padding is supported and expands to size n.
Args:
padding: One of ALLOWED_PADDINGS, or an iterable of them.
n: An integer, the size of the desired output list.
Returns:
If `padding` is one of ALLOWED_PADDINGS, a tuple of size `n... | python | def _fill_and_verify_padding(padding, n):
"""Verifies that the provided padding is supported and expands to size n.
Args:
padding: One of ALLOWED_PADDINGS, or an iterable of them.
n: An integer, the size of the desired output list.
Returns:
If `padding` is one of ALLOWED_PADDINGS, a tuple of size `n... | [
"def",
"_fill_and_verify_padding",
"(",
"padding",
",",
"n",
")",
":",
"if",
"not",
"isinstance",
"(",
"n",
",",
"numbers",
".",
"Integral",
")",
"or",
"n",
"<",
"1",
":",
"raise",
"TypeError",
"(",
"\"n must be a positive integer\"",
")",
"if",
"isinstance"... | Verifies that the provided padding is supported and expands to size n.
Args:
padding: One of ALLOWED_PADDINGS, or an iterable of them.
n: An integer, the size of the desired output list.
Returns:
If `padding` is one of ALLOWED_PADDINGS, a tuple of size `n` containing `n`
copies of `padding`.
I... | [
"Verifies",
"that",
"the",
"provided",
"padding",
"is",
"supported",
"and",
"expands",
"to",
"size",
"n",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L176-L206 | train | Verifies that the provided padding is supported and expands to size n. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _padding_to_conv_op_padding | def _padding_to_conv_op_padding(padding):
"""Whether to use SAME or VALID for the underlying convolution op.
Args:
padding: A tuple of members of ALLOWED_PADDINGS, e.g. as returned from
`_fill_and_verify_padding`.
Returns:
One of CONV_OP_ALLOWED_PADDINGS, the padding method to use for the
unde... | python | def _padding_to_conv_op_padding(padding):
"""Whether to use SAME or VALID for the underlying convolution op.
Args:
padding: A tuple of members of ALLOWED_PADDINGS, e.g. as returned from
`_fill_and_verify_padding`.
Returns:
One of CONV_OP_ALLOWED_PADDINGS, the padding method to use for the
unde... | [
"def",
"_padding_to_conv_op_padding",
"(",
"padding",
")",
":",
"if",
"not",
"isinstance",
"(",
"padding",
",",
"tuple",
")",
":",
"raise",
"ValueError",
"(",
"\"padding should be a tuple.\"",
")",
"if",
"all",
"(",
"p",
"==",
"SAME",
"for",
"p",
"in",
"padd... | Whether to use SAME or VALID for the underlying convolution op.
Args:
padding: A tuple of members of ALLOWED_PADDINGS, e.g. as returned from
`_fill_and_verify_padding`.
Returns:
One of CONV_OP_ALLOWED_PADDINGS, the padding method to use for the
underlying convolution op.
Raises:
ValueErro... | [
"Whether",
"to",
"use",
"SAME",
"or",
"VALID",
"for",
"the",
"underlying",
"convolution",
"op",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L209-L233 | train | Returns a boolean indicating whether to use SAME or VALID for the underlying convolution op. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _fill_and_one_pad_stride | def _fill_and_one_pad_stride(stride, n, data_format=DATA_FORMAT_NHWC):
"""Expands the provided stride to size n and pads it with 1s."""
if isinstance(stride, numbers.Integral) or (
isinstance(stride, collections.Iterable) and len(stride) <= n):
if data_format.startswith("NC"):
return (1, 1,) + _fill... | python | def _fill_and_one_pad_stride(stride, n, data_format=DATA_FORMAT_NHWC):
"""Expands the provided stride to size n and pads it with 1s."""
if isinstance(stride, numbers.Integral) or (
isinstance(stride, collections.Iterable) and len(stride) <= n):
if data_format.startswith("NC"):
return (1, 1,) + _fill... | [
"def",
"_fill_and_one_pad_stride",
"(",
"stride",
",",
"n",
",",
"data_format",
"=",
"DATA_FORMAT_NHWC",
")",
":",
"if",
"isinstance",
"(",
"stride",
",",
"numbers",
".",
"Integral",
")",
"or",
"(",
"isinstance",
"(",
"stride",
",",
"collections",
".",
"Iter... | Expands the provided stride to size n and pads it with 1s. | [
"Expands",
"the",
"provided",
"stride",
"to",
"size",
"n",
"and",
"pads",
"it",
"with",
"1s",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L236-L253 | train | Expands the provided stride to size n and pads it with 1s. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _verify_inputs | def _verify_inputs(inputs, channel_index, data_format):
"""Verifies `inputs` is semantically correct.
Args:
inputs: An input tensor provided by the user.
channel_index: The index of the channel dimension.
data_format: The format of the data in `inputs`.
Raises:
base.IncompatibleShapeError: If th... | python | def _verify_inputs(inputs, channel_index, data_format):
"""Verifies `inputs` is semantically correct.
Args:
inputs: An input tensor provided by the user.
channel_index: The index of the channel dimension.
data_format: The format of the data in `inputs`.
Raises:
base.IncompatibleShapeError: If th... | [
"def",
"_verify_inputs",
"(",
"inputs",
",",
"channel_index",
",",
"data_format",
")",
":",
"# Check shape.",
"input_shape",
"=",
"tuple",
"(",
"inputs",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
")",
"if",
"len",
"(",
"input_shape",
")",
"!=",... | Verifies `inputs` is semantically correct.
Args:
inputs: An input tensor provided by the user.
channel_index: The index of the channel dimension.
data_format: The format of the data in `inputs`.
Raises:
base.IncompatibleShapeError: If the shape of `inputs` doesn't match
`data_format`.
ba... | [
"Verifies",
"inputs",
"is",
"semantically",
"correct",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L256-L292 | train | Verifies that the inputs are semantically correct. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | create_weight_initializer | def create_weight_initializer(fan_in_shape, dtype=tf.float32):
"""Returns a default initializer for the weights of a convolutional module."""
stddev = 1 / math.sqrt(np.prod(fan_in_shape))
return tf.truncated_normal_initializer(stddev=stddev, dtype=dtype) | python | def create_weight_initializer(fan_in_shape, dtype=tf.float32):
"""Returns a default initializer for the weights of a convolutional module."""
stddev = 1 / math.sqrt(np.prod(fan_in_shape))
return tf.truncated_normal_initializer(stddev=stddev, dtype=dtype) | [
"def",
"create_weight_initializer",
"(",
"fan_in_shape",
",",
"dtype",
"=",
"tf",
".",
"float32",
")",
":",
"stddev",
"=",
"1",
"/",
"math",
".",
"sqrt",
"(",
"np",
".",
"prod",
"(",
"fan_in_shape",
")",
")",
"return",
"tf",
".",
"truncated_normal_initiali... | Returns a default initializer for the weights of a convolutional module. | [
"Returns",
"a",
"default",
"initializer",
"for",
"the",
"weights",
"of",
"a",
"convolutional",
"module",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L295-L298 | train | Returns a default initializer for the weights of a convolutional module. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _find_channel_index | def _find_channel_index(data_format):
"""Returns the index of the channel dimension.
Args:
data_format: A string of characters corresponding to Tensor dimensionality.
Returns:
channel_index: An integer indicating the channel dimension.
Raises:
ValueError: If no channel dimension was found.
"""
... | python | def _find_channel_index(data_format):
"""Returns the index of the channel dimension.
Args:
data_format: A string of characters corresponding to Tensor dimensionality.
Returns:
channel_index: An integer indicating the channel dimension.
Raises:
ValueError: If no channel dimension was found.
"""
... | [
"def",
"_find_channel_index",
"(",
"data_format",
")",
":",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
"data_format",
")",
":",
"if",
"c",
"==",
"\"C\"",
":",
"return",
"i",
"raise",
"ValueError",
"(",
"\"data_format requires a channel dimension. Got: {}\"",
... | Returns the index of the channel dimension.
Args:
data_format: A string of characters corresponding to Tensor dimensionality.
Returns:
channel_index: An integer indicating the channel dimension.
Raises:
ValueError: If no channel dimension was found. | [
"Returns",
"the",
"index",
"of",
"the",
"channel",
"dimension",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L306-L322 | train | Returns the index of the channel dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _apply_bias | def _apply_bias(inputs, outputs, channel_index, data_format, output_channels,
initializers, partitioners, regularizers):
"""Initialize and apply a bias to the outputs.
Figures out the shape of the bias vector, initialize it, and applies it.
Args:
inputs: A Tensor of shape `data_format`.
... | python | def _apply_bias(inputs, outputs, channel_index, data_format, output_channels,
initializers, partitioners, regularizers):
"""Initialize and apply a bias to the outputs.
Figures out the shape of the bias vector, initialize it, and applies it.
Args:
inputs: A Tensor of shape `data_format`.
... | [
"def",
"_apply_bias",
"(",
"inputs",
",",
"outputs",
",",
"channel_index",
",",
"data_format",
",",
"output_channels",
",",
"initializers",
",",
"partitioners",
",",
"regularizers",
")",
":",
"bias_shape",
"=",
"(",
"output_channels",
",",
")",
"if",
"\"b\"",
... | Initialize and apply a bias to the outputs.
Figures out the shape of the bias vector, initialize it, and applies it.
Args:
inputs: A Tensor of shape `data_format`.
outputs: A Tensor of shape `data_format`.
channel_index: The index of the channel dimension in `inputs`.
data_format: Format of `input... | [
"Initialize",
"and",
"apply",
"a",
"bias",
"to",
"the",
"outputs",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L325-L369 | train | Initialize and apply a bias to the outputs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvND._build | def _build(self, inputs):
"""Connects the _ConvND module into the graph, with input Tensor `inputs`.
If this is not the first time the module has been connected to the graph,
the input Tensor provided here must have the same number of channels, in
order for the existing variables to be the correct size... | python | def _build(self, inputs):
"""Connects the _ConvND module into the graph, with input Tensor `inputs`.
If this is not the first time the module has been connected to the graph,
the input Tensor provided here must have the same number of channels, in
order for the existing variables to be the correct size... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
")",
":",
"_verify_inputs",
"(",
"inputs",
",",
"self",
".",
"_channel_index",
",",
"self",
".",
"_data_format",
")",
"self",
".",
"_input_shape",
"=",
"tuple",
"(",
"inputs",
".",
"get_shape",
"(",
")",
".",
... | Connects the _ConvND module into the graph, with input Tensor `inputs`.
If this is not the first time the module has been connected to the graph,
the input Tensor provided here must have the same number of channels, in
order for the existing variables to be the correct size for the
multiplication; the ... | [
"Connects",
"the",
"_ConvND",
"module",
"into",
"the",
"graph",
"with",
"input",
"Tensor",
"inputs",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L520-L570 | train | Connects the _ConvND module into the graph with input Tensor inputs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvND._pad_input | def _pad_input(self, inputs):
"""Pad input in case the desired padding type requires it.
VALID and SAME padding types are directly supported by tensorflow
convolution ops, so don't require us to pad input ourselves, at least
in cases where the same method is used for all dimensions.
Other padding ... | python | def _pad_input(self, inputs):
"""Pad input in case the desired padding type requires it.
VALID and SAME padding types are directly supported by tensorflow
convolution ops, so don't require us to pad input ourselves, at least
in cases where the same method is used for all dimensions.
Other padding ... | [
"def",
"_pad_input",
"(",
"self",
",",
"inputs",
")",
":",
"if",
"all",
"(",
"p",
"==",
"self",
".",
"_conv_op_padding",
"for",
"p",
"in",
"self",
".",
"_padding",
")",
":",
"# All axes require the same padding type that we're going to use for the",
"# underlying co... | Pad input in case the desired padding type requires it.
VALID and SAME padding types are directly supported by tensorflow
convolution ops, so don't require us to pad input ourselves, at least
in cases where the same method is used for all dimensions.
Other padding types (FULL, CAUSAL, REVERSE_CAUSAL) ... | [
"Pad",
"input",
"in",
"case",
"the",
"desired",
"padding",
"type",
"requires",
"it",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L572-L626 | train | Pads the input tensor with the desired padding type. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvND._apply_conv | def _apply_conv(self, inputs, w):
"""Apply a convolution operation on `inputs` using variable `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A weight matrix of the same type as `inputs`.
Returns:
outputs: The resul... | python | def _apply_conv(self, inputs, w):
"""Apply a convolution operation on `inputs` using variable `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A weight matrix of the same type as `inputs`.
Returns:
outputs: The resul... | [
"def",
"_apply_conv",
"(",
"self",
",",
"inputs",
",",
"w",
")",
":",
"outputs",
"=",
"tf",
".",
"nn",
".",
"convolution",
"(",
"inputs",
",",
"w",
",",
"strides",
"=",
"self",
".",
"_stride",
",",
"padding",
"=",
"self",
".",
"_conv_op_padding",
","... | Apply a convolution operation on `inputs` using variable `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A weight matrix of the same type as `inputs`.
Returns:
outputs: The result of the convolution operation on `inputs... | [
"Apply",
"a",
"convolution",
"operation",
"on",
"inputs",
"using",
"variable",
"w",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L628-L643 | train | Applies a convolution operation on inputs using variable w. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvND._apply_mask | def _apply_mask(self):
"""Applies the passed-in mask to the convolution matrix.
Returns:
w: A copy of the convolution matrix that has had the mask applied.
Raises:
base.IncompatibleShapeError: If the mask shape has more dimensions than
the weight matrix.
base.IncompatibleShapeE... | python | def _apply_mask(self):
"""Applies the passed-in mask to the convolution matrix.
Returns:
w: A copy of the convolution matrix that has had the mask applied.
Raises:
base.IncompatibleShapeError: If the mask shape has more dimensions than
the weight matrix.
base.IncompatibleShapeE... | [
"def",
"_apply_mask",
"(",
"self",
")",
":",
"w",
"=",
"self",
".",
"_w",
"w_shape",
"=",
"w",
".",
"get_shape",
"(",
")",
"mask_shape",
"=",
"self",
".",
"_mask",
".",
"get_shape",
"(",
")",
"if",
"mask_shape",
".",
"ndims",
">",
"w_shape",
".",
"... | Applies the passed-in mask to the convolution matrix.
Returns:
w: A copy of the convolution matrix that has had the mask applied.
Raises:
base.IncompatibleShapeError: If the mask shape has more dimensions than
the weight matrix.
base.IncompatibleShapeError: If the mask and the weig... | [
"Applies",
"the",
"passed",
"-",
"in",
"mask",
"to",
"the",
"convolution",
"matrix",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L673-L710 | train | Applies the passed - in mask to the convolution matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvND.output_channels | def output_channels(self):
"""Returns the number of output channels."""
if callable(self._output_channels):
self._output_channels = self._output_channels()
# Channel must be integer.
self._output_channels = int(self._output_channels)
return self._output_channels | python | def output_channels(self):
"""Returns the number of output channels."""
if callable(self._output_channels):
self._output_channels = self._output_channels()
# Channel must be integer.
self._output_channels = int(self._output_channels)
return self._output_channels | [
"def",
"output_channels",
"(",
"self",
")",
":",
"if",
"callable",
"(",
"self",
".",
"_output_channels",
")",
":",
"self",
".",
"_output_channels",
"=",
"self",
".",
"_output_channels",
"(",
")",
"# Channel must be integer.",
"self",
".",
"_output_channels",
"="... | Returns the number of output channels. | [
"Returns",
"the",
"number",
"of",
"output",
"channels",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L713-L719 | train | Returns the number of output channels. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvND.padding | def padding(self):
"""Returns the padding algorithm used, if this is the same for all dims.
Use `.paddings` if you want a tuple with the padding algorithm used for each
dimension.
Returns:
The padding algorithm used, if this is the same for all dimensions.
Raises:
ValueError: If diffe... | python | def padding(self):
"""Returns the padding algorithm used, if this is the same for all dims.
Use `.paddings` if you want a tuple with the padding algorithm used for each
dimension.
Returns:
The padding algorithm used, if this is the same for all dimensions.
Raises:
ValueError: If diffe... | [
"def",
"padding",
"(",
"self",
")",
":",
"# This is for backwards compatibility -- previously only a single",
"# padding setting was supported across all dimensions.",
"if",
"all",
"(",
"p",
"==",
"self",
".",
"_padding",
"[",
"0",
"]",
"for",
"p",
"in",
"self",
".",
... | Returns the padding algorithm used, if this is the same for all dims.
Use `.paddings` if you want a tuple with the padding algorithm used for each
dimension.
Returns:
The padding algorithm used, if this is the same for all dimensions.
Raises:
ValueError: If different padding algorithms ar... | [
"Returns",
"the",
"padding",
"algorithm",
"used",
"if",
"this",
"is",
"the",
"same",
"for",
"all",
"dims",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L739-L759 | train | Returns the padding algorithm used for each
SearchResult dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvND.clone | def clone(self, name=None):
"""Returns a cloned `_ConvND` module.
Args:
name: Optional string assigning name of cloned module. The default name
is constructed by appending "_clone" to `self.module_name`.
Returns:
A copy of the current class.
"""
if name is None:
name = se... | python | def clone(self, name=None):
"""Returns a cloned `_ConvND` module.
Args:
name: Optional string assigning name of cloned module. The default name
is constructed by appending "_clone" to `self.module_name`.
Returns:
A copy of the current class.
"""
if name is None:
name = se... | [
"def",
"clone",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"module_name",
"+",
"\"_clone\"",
"return",
"type",
"(",
"self",
")",
"(",
"output_channels",
"=",
"self",
".",
"output_channels... | Returns a cloned `_ConvND` module.
Args:
name: Optional string assigning name of cloned module. The default name
is constructed by appending "_clone" to `self.module_name`.
Returns:
A copy of the current class. | [
"Returns",
"a",
"cloned",
"_ConvND",
"module",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L839-L864 | train | Returns a copy of the current module. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvNDTranspose._build | def _build(self, inputs):
"""Connects the _ConvNDTranspose module into the graph.
If this is not the first time the module has been connected to the graph,
the input Tensor provided here must have the same final N dimensions, in
order for the existing variables to be the correct size for the
multip... | python | def _build(self, inputs):
"""Connects the _ConvNDTranspose module into the graph.
If this is not the first time the module has been connected to the graph,
the input Tensor provided here must have the same final N dimensions, in
order for the existing variables to be the correct size for the
multip... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
")",
":",
"_verify_inputs",
"(",
"inputs",
",",
"self",
".",
"_channel_index",
",",
"self",
".",
"_data_format",
")",
"self",
".",
"_input_shape",
"=",
"tuple",
"(",
"inputs",
".",
"get_shape",
"(",
")",
".",
... | Connects the _ConvNDTranspose module into the graph.
If this is not the first time the module has been connected to the graph,
the input Tensor provided here must have the same final N dimensions, in
order for the existing variables to be the correct size for the
multiplication. The batch size may diff... | [
"Connects",
"the",
"_ConvNDTranspose",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L994-L1093 | train | Connects the _ConvNDTranspose module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvNDTranspose._infer_all_output_dims | def _infer_all_output_dims(self, inputs):
"""Calculate the output shape for `inputs` after a deconvolution.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
output_shape: A tensor of shape (`batch_size`, `conv_output_shap... | python | def _infer_all_output_dims(self, inputs):
"""Calculate the output shape for `inputs` after a deconvolution.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
output_shape: A tensor of shape (`batch_size`, `conv_output_shap... | [
"def",
"_infer_all_output_dims",
"(",
"self",
",",
"inputs",
")",
":",
"# Use tensorflow shape op to manipulate inputs shape, so that unknown batch",
"# size - which can happen when using input placeholders - is handled",
"# correcly.",
"batch_size",
"=",
"tf",
".",
"expand_dims",
"(... | Calculate the output shape for `inputs` after a deconvolution.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
output_shape: A tensor of shape (`batch_size`, `conv_output_shape`). | [
"Calculate",
"the",
"output",
"shape",
"for",
"inputs",
"after",
"a",
"deconvolution",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1128-L1157 | train | Infer the output shape for inputs after a deconvolution. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvNDTranspose._recover_shape_information | def _recover_shape_information(self, inputs, outputs):
"""Recover output tensor shape value to enable shape inference.
The batch size of `inputs` isn't preserved by the convolution op. Calculate
what the proper output shape will be for `outputs`.
Args:
inputs: A Tensor of shape `data_format` and... | python | def _recover_shape_information(self, inputs, outputs):
"""Recover output tensor shape value to enable shape inference.
The batch size of `inputs` isn't preserved by the convolution op. Calculate
what the proper output shape will be for `outputs`.
Args:
inputs: A Tensor of shape `data_format` and... | [
"def",
"_recover_shape_information",
"(",
"self",
",",
"inputs",
",",
"outputs",
")",
":",
"batch_size_value",
"=",
"inputs",
".",
"get_shape",
"(",
")",
"[",
"0",
"]",
"if",
"self",
".",
"_data_format",
".",
"startswith",
"(",
"\"NC\"",
")",
":",
"output_... | Recover output tensor shape value to enable shape inference.
The batch size of `inputs` isn't preserved by the convolution op. Calculate
what the proper output shape will be for `outputs`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`... | [
"Recover",
"output",
"tensor",
"shape",
"value",
"to",
"enable",
"shape",
"inference",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1159-L1183 | train | Recover output tensor shape value to enable shape inference. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | _ConvNDTranspose.output_shape | def output_shape(self):
"""Returns the output shape."""
if self._output_shape is None:
self._ensure_is_connected()
if callable(self._output_shape):
self._output_shape = tuple(self._output_shape())
return self._output_shape | python | def output_shape(self):
"""Returns the output shape."""
if self._output_shape is None:
self._ensure_is_connected()
if callable(self._output_shape):
self._output_shape = tuple(self._output_shape())
return self._output_shape | [
"def",
"output_shape",
"(",
"self",
")",
":",
"if",
"self",
".",
"_output_shape",
"is",
"None",
":",
"self",
".",
"_ensure_is_connected",
"(",
")",
"if",
"callable",
"(",
"self",
".",
"_output_shape",
")",
":",
"self",
".",
"_output_shape",
"=",
"tuple",
... | Returns the output shape. | [
"Returns",
"the",
"output",
"shape",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1205-L1211 | train | Returns the output shape of the current node. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | Conv1DTranspose.transpose | def transpose(self, name=None):
"""Returns matching `Conv1D` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv1D` module.
"""
if name is None:
name = self.module... | python | def transpose(self, name=None):
"""Returns matching `Conv1D` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv1D` module.
"""
if name is None:
name = self.module... | [
"def",
"transpose",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"module_name",
"+",
"\"_transpose\"",
"if",
"self",
".",
"_data_format",
"==",
"DATA_FORMAT_NWC",
":",
"stride",
"=",
"self",
... | Returns matching `Conv1D` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv1D` module. | [
"Returns",
"matching",
"Conv1D",
"module",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1517-L1545 | train | Returns matching Conv1D module. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | Conv2D.transpose | def transpose(self, name=None):
"""Returns matching `Conv2DTranspose` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv2DTranspose` module.
Raises:
base.NotSupported... | python | def transpose(self, name=None):
"""Returns matching `Conv2DTranspose` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv2DTranspose` module.
Raises:
base.NotSupported... | [
"def",
"transpose",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"any",
"(",
"x",
">",
"1",
"for",
"x",
"in",
"self",
".",
"_rate",
")",
":",
"raise",
"base",
".",
"NotSupportedError",
"(",
"\"Cannot transpose a dilated convolution module.\"",
")... | Returns matching `Conv2DTranspose` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv2DTranspose` module.
Raises:
base.NotSupportedError: If `rate` in any dimension > 1. | [
"Returns",
"matching",
"Conv2DTranspose",
"module",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1760-L1802 | train | Returns a new module with matching input channels and output channels. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | Conv2DTranspose.transpose | def transpose(self, name=None):
"""Returns matching `Conv2D` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv2D` module.
"""
if name is None:
name = self.modu... | python | def transpose(self, name=None):
"""Returns matching `Conv2D` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv2D` module.
"""
if name is None:
name = self.modu... | [
"def",
"transpose",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"module_name",
"+",
"\"_transpose\"",
"if",
"self",
".",
"_data_format",
"==",
"DATA_FORMAT_NHWC",
":",
"stride",
"=",
"self",... | Returns matching `Conv2D` module.
Args:
name: Optional string assigning name of transpose module. The default name
is constructed by appending "_transpose" to `self.name`.
Returns:
`Conv2D` module. | [
"Returns",
"matching",
"Conv2D",
"module",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L1892-L1920 | train | Returns matching Conv2D module. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | InPlaneConv2D._construct_w | def _construct_w(self, inputs):
"""Construct the convolution weight matrix.
Figures out the shape of the weight matrix, initialize it, and return it.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
w: A weight matri... | python | def _construct_w(self, inputs):
"""Construct the convolution weight matrix.
Figures out the shape of the weight matrix, initialize it, and return it.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
w: A weight matri... | [
"def",
"_construct_w",
"(",
"self",
",",
"inputs",
")",
":",
"weight_shape",
"=",
"self",
".",
"_kernel_shape",
"+",
"(",
"1",
",",
"1",
")",
"if",
"\"w\"",
"not",
"in",
"self",
".",
"_initializers",
":",
"self",
".",
"_initializers",
"[",
"\"w\"",
"]"... | Construct the convolution weight matrix.
Figures out the shape of the weight matrix, initialize it, and return it.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
Returns:
w: A weight matrix of the same type as `inputs` and of s... | [
"Construct",
"the",
"convolution",
"weight",
"matrix",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2270-L2295 | train | Constructs the convolution weight matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | InPlaneConv2D._apply_conv | def _apply_conv(self, inputs, w):
"""Apply a depthwise_conv2d operation on `inputs` using variable `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A weight matrix of the same type as `inputs`.
Returns:
outputs: The ... | python | def _apply_conv(self, inputs, w):
"""Apply a depthwise_conv2d operation on `inputs` using variable `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A weight matrix of the same type as `inputs`.
Returns:
outputs: The ... | [
"def",
"_apply_conv",
"(",
"self",
",",
"inputs",
",",
"w",
")",
":",
"tiled_weights",
"=",
"tf",
".",
"tile",
"(",
"w",
",",
"[",
"1",
",",
"1",
",",
"self",
".",
"_input_channels",
",",
"1",
"]",
")",
"outputs",
"=",
"tf",
".",
"nn",
".",
"de... | Apply a depthwise_conv2d operation on `inputs` using variable `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A weight matrix of the same type as `inputs`.
Returns:
outputs: The result of the convolution operation on `i... | [
"Apply",
"a",
"depthwise_conv2d",
"operation",
"on",
"inputs",
"using",
"variable",
"w",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2297-L2314 | train | Applies a depthwise_conv2d operation on inputs using variable w. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | SeparableConv2D._construct_w | def _construct_w(self, inputs):
"""Connects the module into the graph, with input Tensor `inputs`.
Args:
inputs: A 4D Tensor of shape:
[batch_size, input_height, input_width, input_channels]
and of type `tf.float16`, `tf.bfloat16` or `tf.float32`.
Returns:
A tuple of two 4D... | python | def _construct_w(self, inputs):
"""Connects the module into the graph, with input Tensor `inputs`.
Args:
inputs: A 4D Tensor of shape:
[batch_size, input_height, input_width, input_channels]
and of type `tf.float16`, `tf.bfloat16` or `tf.float32`.
Returns:
A tuple of two 4D... | [
"def",
"_construct_w",
"(",
"self",
",",
"inputs",
")",
":",
"depthwise_weight_shape",
"=",
"self",
".",
"_kernel_shape",
"+",
"(",
"self",
".",
"_input_channels",
",",
"self",
".",
"_channel_multiplier",
")",
"pointwise_input_size",
"=",
"self",
".",
"_channel_... | Connects the module into the graph, with input Tensor `inputs`.
Args:
inputs: A 4D Tensor of shape:
[batch_size, input_height, input_width, input_channels]
and of type `tf.float16`, `tf.bfloat16` or `tf.float32`.
Returns:
A tuple of two 4D Tensors, each with the same dtype as `... | [
"Connects",
"the",
"module",
"into",
"the",
"graph",
"with",
"input",
"Tensor",
"inputs",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2631-L2677 | train | Connects the module into the graph with input Tensor inputs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | SeparableConv2D._apply_conv | def _apply_conv(self, inputs, w):
"""Apply a `separable_conv2d` operation on `inputs` using `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A tuple of weight matrices of the same type as `inputs`, the first
being the d... | python | def _apply_conv(self, inputs, w):
"""Apply a `separable_conv2d` operation on `inputs` using `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A tuple of weight matrices of the same type as `inputs`, the first
being the d... | [
"def",
"_apply_conv",
"(",
"self",
",",
"inputs",
",",
"w",
")",
":",
"w_dw",
",",
"w_pw",
"=",
"w",
"outputs",
"=",
"tf",
".",
"nn",
".",
"separable_conv2d",
"(",
"inputs",
",",
"w_dw",
",",
"w_pw",
",",
"rate",
"=",
"self",
".",
"_rate",
",",
"... | Apply a `separable_conv2d` operation on `inputs` using `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A tuple of weight matrices of the same type as `inputs`, the first
being the depthwise weight matrix, and the second be... | [
"Apply",
"a",
"separable_conv2d",
"operation",
"on",
"inputs",
"using",
"w",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2679-L2700 | train | Applies a sequential_conv2d operation on inputs using w. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/conv.py | SeparableConv1D._apply_conv | def _apply_conv(self, inputs, w):
"""Apply a `separable_conv2d` operation on `inputs` using `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A tuple of weight matrices of the same type as `inputs`, the first
being the d... | python | def _apply_conv(self, inputs, w):
"""Apply a `separable_conv2d` operation on `inputs` using `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A tuple of weight matrices of the same type as `inputs`, the first
being the d... | [
"def",
"_apply_conv",
"(",
"self",
",",
"inputs",
",",
"w",
")",
":",
"if",
"self",
".",
"_data_format",
"==",
"DATA_FORMAT_NWC",
":",
"h_dim",
"=",
"1",
"two_dim_conv_data_format",
"=",
"DATA_FORMAT_NHWC",
"else",
":",
"h_dim",
"=",
"2",
"two_dim_conv_data_fo... | Apply a `separable_conv2d` operation on `inputs` using `w`.
Args:
inputs: A Tensor of shape `data_format` and of type `tf.float16`,
`tf.bfloat16` or `tf.float32`.
w: A tuple of weight matrices of the same type as `inputs`, the first
being the depthwise weight matrix, and the second be... | [
"Apply",
"a",
"separable_conv2d",
"operation",
"on",
"inputs",
"using",
"w",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/conv.py#L2905-L2940 | train | Applies a sequential_conv2d operation on inputs using w. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/sequential.py | Sequential._build | def _build(self, *args):
"""Connects the Sequential module into the graph.
Args:
*args: A tuple of inputs, to be unpacked as the arguments to the first
layer.
Returns:
The output value of the last layer.
"""
net = args
if not self._layers:
# If the sequential is pa... | python | def _build(self, *args):
"""Connects the Sequential module into the graph.
Args:
*args: A tuple of inputs, to be unpacked as the arguments to the first
layer.
Returns:
The output value of the last layer.
"""
net = args
if not self._layers:
# If the sequential is pa... | [
"def",
"_build",
"(",
"self",
",",
"*",
"args",
")",
":",
"net",
"=",
"args",
"if",
"not",
"self",
".",
"_layers",
":",
"# If the sequential is passed a single arg, this will end up being",
"# wrapped in an extra layer of tuple by *args. Normally we internally",
"# handle thi... | Connects the Sequential module into the graph.
Args:
*args: A tuple of inputs, to be unpacked as the arguments to the first
layer.
Returns:
The output value of the last layer. | [
"Connects",
"the",
"Sequential",
"module",
"into",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/sequential.py#L79-L107 | train | Connects the Sequential module into the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/sequential.py | Sequential.get_variables | def get_variables(self, *args, **kwargs):
"""Provide a warning that get_variables on Sequential always returns ()."""
tf.logging.warning(
"Calling Sequential.get_variables, which will always return an empty "
"tuple. get_variables() can only return variables created directly by "
"a Modu... | python | def get_variables(self, *args, **kwargs):
"""Provide a warning that get_variables on Sequential always returns ()."""
tf.logging.warning(
"Calling Sequential.get_variables, which will always return an empty "
"tuple. get_variables() can only return variables created directly by "
"a Modu... | [
"def",
"get_variables",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tf",
".",
"logging",
".",
"warning",
"(",
"\"Calling Sequential.get_variables, which will always return an empty \"",
"\"tuple. get_variables() can only return variables created directl... | Provide a warning that get_variables on Sequential always returns (). | [
"Provide",
"a",
"warning",
"that",
"get_variables",
"on",
"Sequential",
"always",
"returns",
"()",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/sequential.py#L113-L124 | train | Provide a warning that get_variables on Sequential always returns an empty tuple. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/custom_getters/override_args.py | override_args | def override_args(**kwargs):
"""Creates a custom getter that applies specified named arguments.
Args:
**kwargs: Overriding arguments for the custom getter to use in preference
the named arguments it's called with.
Returns:
Custom getter.
"""
override_kwargs = kwargs
def custom_getter(gette... | python | def override_args(**kwargs):
"""Creates a custom getter that applies specified named arguments.
Args:
**kwargs: Overriding arguments for the custom getter to use in preference
the named arguments it's called with.
Returns:
Custom getter.
"""
override_kwargs = kwargs
def custom_getter(gette... | [
"def",
"override_args",
"(",
"*",
"*",
"kwargs",
")",
":",
"override_kwargs",
"=",
"kwargs",
"def",
"custom_getter",
"(",
"getter",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Custom getter with certain named arguments overridden.\n\n Args:\n g... | Creates a custom getter that applies specified named arguments.
Args:
**kwargs: Overriding arguments for the custom getter to use in preference
the named arguments it's called with.
Returns:
Custom getter. | [
"Creates",
"a",
"custom",
"getter",
"that",
"applies",
"specified",
"named",
"arguments",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/custom_getters/override_args.py#L24-L52 | train | Creates a custom getter that applies specified named arguments. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/custom_getters/override_args.py | override_default_args | def override_default_args(**kwargs):
"""Creates a custom getter that applies specified named arguments.
The returned custom getter treats the specified named arguments as revised
defaults, and does not override any non-`None` argument values supplied by
the original get_variable call (or by a nested scope's cu... | python | def override_default_args(**kwargs):
"""Creates a custom getter that applies specified named arguments.
The returned custom getter treats the specified named arguments as revised
defaults, and does not override any non-`None` argument values supplied by
the original get_variable call (or by a nested scope's cu... | [
"def",
"override_default_args",
"(",
"*",
"*",
"kwargs",
")",
":",
"override_default_kwargs",
"=",
"kwargs",
"def",
"custom_getter",
"(",
"getter",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Custom getter with certain named arguments overridden.\n\n ... | Creates a custom getter that applies specified named arguments.
The returned custom getter treats the specified named arguments as revised
defaults, and does not override any non-`None` argument values supplied by
the original get_variable call (or by a nested scope's custom getter).
Args:
**kwargs: Overr... | [
"Creates",
"a",
"custom",
"getter",
"that",
"applies",
"specified",
"named",
"arguments",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/custom_getters/override_args.py#L55-L89 | train | Creates a custom getter that applies specified named arguments. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/util/migrate_checkpoint.py | _build_migrated_variables | def _build_migrated_variables(checkpoint_reader, name_value_fn):
"""Builds the TensorFlow variables of the migrated checkpoint.
Args:
checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to
be read from.
name_value_fn: Function taking two arguments, `name` and `value`, which
re... | python | def _build_migrated_variables(checkpoint_reader, name_value_fn):
"""Builds the TensorFlow variables of the migrated checkpoint.
Args:
checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to
be read from.
name_value_fn: Function taking two arguments, `name` and `value`, which
re... | [
"def",
"_build_migrated_variables",
"(",
"checkpoint_reader",
",",
"name_value_fn",
")",
":",
"names_to_shapes",
"=",
"checkpoint_reader",
".",
"get_variable_to_shape_map",
"(",
")",
"new_name_to_variable",
"=",
"{",
"}",
"name_to_new_name",
"=",
"{",
"}",
"for",
"nam... | Builds the TensorFlow variables of the migrated checkpoint.
Args:
checkpoint_reader: A `tf.train.NewCheckPointReader` of the checkpoint to
be read from.
name_value_fn: Function taking two arguments, `name` and `value`, which
returns the pair of new name and value for that a variable of that name.... | [
"Builds",
"the",
"TensorFlow",
"variables",
"of",
"the",
"migrated",
"checkpoint",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/util/migrate_checkpoint.py#L33-L62 | train | Builds the TensorFlow variables of the migrated checkpoint. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/base_info.py | _to_proto_sparse_tensor | def _to_proto_sparse_tensor(sparse_tensor, nested_proto,
process_leafs, already_processed):
"""Serializes a `tf.SparseTensor` into `nested_proto`.
Args:
sparse_tensor: An instance of `tf.SparseTensor`.
nested_proto: A `module_pb2.NestedData` instance to be filled from
`spa... | python | def _to_proto_sparse_tensor(sparse_tensor, nested_proto,
process_leafs, already_processed):
"""Serializes a `tf.SparseTensor` into `nested_proto`.
Args:
sparse_tensor: An instance of `tf.SparseTensor`.
nested_proto: A `module_pb2.NestedData` instance to be filled from
`spa... | [
"def",
"_to_proto_sparse_tensor",
"(",
"sparse_tensor",
",",
"nested_proto",
",",
"process_leafs",
",",
"already_processed",
")",
":",
"already_processed",
".",
"add",
"(",
"id",
"(",
"sparse_tensor",
")",
")",
"nested_proto",
".",
"named_tuple",
".",
"name",
"=",... | Serializes a `tf.SparseTensor` into `nested_proto`.
Args:
sparse_tensor: An instance of `tf.SparseTensor`.
nested_proto: A `module_pb2.NestedData` instance to be filled from
`sparse_tensor`.
process_leafs: A function to be applied to the leaf valued of the nested
structure.
already_proces... | [
"Serializes",
"a",
"tf",
".",
"SparseTensor",
"into",
"nested_proto",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L99-L116 | train | Serializes a tf. SparseTensor into nested_proto. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/base_info.py | _from_proto_sparse_tensor | def _from_proto_sparse_tensor(sparse_tensor_proto, process_leafs):
"""Deserializes a `tf.SparseTensor` from `sparse_tensor_proto`.
Args:
sparse_tensor_proto: A proto representing a `tf.SparseTensor`.
process_leafs: A function to be applied to the leaf valued of the nested
structure.
Returns:
A... | python | def _from_proto_sparse_tensor(sparse_tensor_proto, process_leafs):
"""Deserializes a `tf.SparseTensor` from `sparse_tensor_proto`.
Args:
sparse_tensor_proto: A proto representing a `tf.SparseTensor`.
process_leafs: A function to be applied to the leaf valued of the nested
structure.
Returns:
A... | [
"def",
"_from_proto_sparse_tensor",
"(",
"sparse_tensor_proto",
",",
"process_leafs",
")",
":",
"if",
"not",
"sparse_tensor_proto",
".",
"HasField",
"(",
"\"named_tuple\"",
")",
":",
"raise",
"base_errors",
".",
"ModuleInfoError",
"(",
"\"Error while deserializing a Spars... | Deserializes a `tf.SparseTensor` from `sparse_tensor_proto`.
Args:
sparse_tensor_proto: A proto representing a `tf.SparseTensor`.
process_leafs: A function to be applied to the leaf valued of the nested
structure.
Returns:
An instance of `tf.SparseTensor`. | [
"Deserializes",
"a",
"tf",
".",
"SparseTensor",
"from",
"sparse_tensor_proto",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L119-L142 | train | Deserializes a tf. SparseTensor from a protobuf. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/base_info.py | _nested_to_proto | def _nested_to_proto(nested_value, nested_proto, process_leafs,
already_processed):
"""Serializes `nested_value` into `nested_proto`.
Args:
nested_value: A nested Python value.
nested_proto: A `module_pb2.NestedData` instance to be filled from the value
in `nested_value`.
pro... | python | def _nested_to_proto(nested_value, nested_proto, process_leafs,
already_processed):
"""Serializes `nested_value` into `nested_proto`.
Args:
nested_value: A nested Python value.
nested_proto: A `module_pb2.NestedData` instance to be filled from the value
in `nested_value`.
pro... | [
"def",
"_nested_to_proto",
"(",
"nested_value",
",",
"nested_proto",
",",
"process_leafs",
",",
"already_processed",
")",
":",
"if",
"not",
"isinstance",
"(",
"nested_proto",
",",
"module_pb2",
".",
"NestedData",
")",
":",
"raise",
"base_errors",
".",
"ModuleInfoE... | Serializes `nested_value` into `nested_proto`.
Args:
nested_value: A nested Python value.
nested_proto: A `module_pb2.NestedData` instance to be filled from the value
in `nested_value`.
process_leafs: A function to be applied to the leaf values of the nested
structure.
already_processed: ... | [
"Serializes",
"nested_value",
"into",
"nested_proto",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L160-L223 | train | Serializes a nested Python value into a nested_proto. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/base_info.py | _module_info_to_proto | def _module_info_to_proto(module_info, export_scope=None):
"""Serializes `module_into`.
Args:
module_info: An instance of `ModuleInfo`.
export_scope: Optional `string`. Name scope to remove.
Returns:
An instance of `module_pb2.SonnetModule`.
"""
def strip_name_scope(name_scope):
return ops.s... | python | def _module_info_to_proto(module_info, export_scope=None):
"""Serializes `module_into`.
Args:
module_info: An instance of `ModuleInfo`.
export_scope: Optional `string`. Name scope to remove.
Returns:
An instance of `module_pb2.SonnetModule`.
"""
def strip_name_scope(name_scope):
return ops.s... | [
"def",
"_module_info_to_proto",
"(",
"module_info",
",",
"export_scope",
"=",
"None",
")",
":",
"def",
"strip_name_scope",
"(",
"name_scope",
")",
":",
"return",
"ops",
".",
"strip_name_scope",
"(",
"name_scope",
",",
"export_scope",
")",
"def",
"process_leafs",
... | Serializes `module_into`.
Args:
module_info: An instance of `ModuleInfo`.
export_scope: Optional `string`. Name scope to remove.
Returns:
An instance of `module_pb2.SonnetModule`. | [
"Serializes",
"module_into",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L226-L256 | train | Serializes a module_info into a proto2. SonnetModule. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/base_info.py | _nested_from_proto | def _nested_from_proto(nested_proto, process_leafs):
"""Deserializes `nested_proto`.
Args:
nested_proto: An instance of `module_pb2.NestedData`.
process_leafs: A function to be applied to the leaf values of the nested
structure.
Returns:
An instance of `string`, `tuple`, `dict` or `namedtuple`... | python | def _nested_from_proto(nested_proto, process_leafs):
"""Deserializes `nested_proto`.
Args:
nested_proto: An instance of `module_pb2.NestedData`.
process_leafs: A function to be applied to the leaf values of the nested
structure.
Returns:
An instance of `string`, `tuple`, `dict` or `namedtuple`... | [
"def",
"_nested_from_proto",
"(",
"nested_proto",
",",
"process_leafs",
")",
":",
"if",
"not",
"isinstance",
"(",
"nested_proto",
",",
"module_pb2",
".",
"NestedData",
")",
":",
"raise",
"base_errors",
".",
"ModuleInfoError",
"(",
"\"Expected module_pb2.NestedData.\""... | Deserializes `nested_proto`.
Args:
nested_proto: An instance of `module_pb2.NestedData`.
process_leafs: A function to be applied to the leaf values of the nested
structure.
Returns:
An instance of `string`, `tuple`, `dict` or `namedtuple`.
Raises:
base_errors.ModuleInfoError: If the probo... | [
"Deserializes",
"nested_proto",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L259-L307 | train | Deserializes nested_proto into a new object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/base_info.py | _module_info_from_proto | def _module_info_from_proto(module_info_def, import_scope=None):
"""Deserializes `module_info_def` proto.
Args:
module_info_def: An instance of `module_pb2.SonnetModule`.
import_scope: Optional `string`. Name scope to use.
Returns:
An instance of `ModuleInfo`.
Raises:
base_errors.ModuleInfoEr... | python | def _module_info_from_proto(module_info_def, import_scope=None):
"""Deserializes `module_info_def` proto.
Args:
module_info_def: An instance of `module_pb2.SonnetModule`.
import_scope: Optional `string`. Name scope to use.
Returns:
An instance of `ModuleInfo`.
Raises:
base_errors.ModuleInfoEr... | [
"def",
"_module_info_from_proto",
"(",
"module_info_def",
",",
"import_scope",
"=",
"None",
")",
":",
"graph",
"=",
"tf",
".",
"get_default_graph",
"(",
")",
"def",
"prepend_name_scope",
"(",
"name_scope",
")",
":",
"return",
"ops",
".",
"prepend_name_scope",
"(... | Deserializes `module_info_def` proto.
Args:
module_info_def: An instance of `module_pb2.SonnetModule`.
import_scope: Optional `string`. Name scope to use.
Returns:
An instance of `ModuleInfo`.
Raises:
base_errors.ModuleInfoError: If the probobuf is of the wrong type or
if some of its fiel... | [
"Deserializes",
"module_info_def",
"proto",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L310-L344 | train | Deserializes module_info_def proto. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/base_info.py | _module_info_from_proto_safe | def _module_info_from_proto_safe(module_info_def, import_scope=None):
"""Deserializes the `module_info_def` proto without raising exceptions.
Args:
module_info_def: An instance of `module_pb2.SonnetModule`.
import_scope: Optional `string`. Name scope to use.
Returns:
An instance of `ModuleInfo`.
"... | python | def _module_info_from_proto_safe(module_info_def, import_scope=None):
"""Deserializes the `module_info_def` proto without raising exceptions.
Args:
module_info_def: An instance of `module_pb2.SonnetModule`.
import_scope: Optional `string`. Name scope to use.
Returns:
An instance of `ModuleInfo`.
"... | [
"def",
"_module_info_from_proto_safe",
"(",
"module_info_def",
",",
"import_scope",
"=",
"None",
")",
":",
"try",
":",
"return",
"_module_info_from_proto",
"(",
"module_info_def",
",",
"import_scope",
")",
"except",
"Exception",
"as",
"e",
":",
"# pylint: disable=broa... | Deserializes the `module_info_def` proto without raising exceptions.
Args:
module_info_def: An instance of `module_pb2.SonnetModule`.
import_scope: Optional `string`. Name scope to use.
Returns:
An instance of `ModuleInfo`. | [
"Deserializes",
"the",
"module_info_def",
"proto",
"without",
"raising",
"exceptions",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/base_info.py#L347-L362 | train | Deserializes the module_info_def proto without raising exceptions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/rnn_shakespeare.py | _configure_saver | def _configure_saver(checkpoint_dir, checkpoint_interval):
"""Returns a tf.train.CheckpointSaverHook for autosaving checkpoints."""
saver = tf.train.Saver()
return tf.train.CheckpointSaverHook(
checkpoint_dir=checkpoint_dir,
save_steps=checkpoint_interval,
saver=saver) | python | def _configure_saver(checkpoint_dir, checkpoint_interval):
"""Returns a tf.train.CheckpointSaverHook for autosaving checkpoints."""
saver = tf.train.Saver()
return tf.train.CheckpointSaverHook(
checkpoint_dir=checkpoint_dir,
save_steps=checkpoint_interval,
saver=saver) | [
"def",
"_configure_saver",
"(",
"checkpoint_dir",
",",
"checkpoint_interval",
")",
":",
"saver",
"=",
"tf",
".",
"train",
".",
"Saver",
"(",
")",
"return",
"tf",
".",
"train",
".",
"CheckpointSaverHook",
"(",
"checkpoint_dir",
"=",
"checkpoint_dir",
",",
"save... | Returns a tf.train.CheckpointSaverHook for autosaving checkpoints. | [
"Returns",
"a",
"tf",
".",
"train",
".",
"CheckpointSaverHook",
"for",
"autosaving",
"checkpoints",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L55-L61 | train | Returns a tf. train. CheckpointSaverHook for autosaving checkpoints. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/rnn_shakespeare.py | build_graph | def build_graph(lstm_depth=3, batch_size=32, num_embedding=32, num_hidden=128,
truncation_length=64, sample_length=1000, max_grad_norm=5,
initial_learning_rate=0.1, reduce_learning_rate_multiplier=0.1,
optimizer_epsilon=0.01):
"""Constructs the computation graph."""
... | python | def build_graph(lstm_depth=3, batch_size=32, num_embedding=32, num_hidden=128,
truncation_length=64, sample_length=1000, max_grad_norm=5,
initial_learning_rate=0.1, reduce_learning_rate_multiplier=0.1,
optimizer_epsilon=0.01):
"""Constructs the computation graph."""
... | [
"def",
"build_graph",
"(",
"lstm_depth",
"=",
"3",
",",
"batch_size",
"=",
"32",
",",
"num_embedding",
"=",
"32",
",",
"num_hidden",
"=",
"128",
",",
"truncation_length",
"=",
"64",
",",
"sample_length",
"=",
"1000",
",",
"max_grad_norm",
"=",
"5",
",",
... | Constructs the computation graph. | [
"Constructs",
"the",
"computation",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L64-L168 | train | Constructs the computation graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/rnn_shakespeare.py | train | def train(num_training_iterations, report_interval,
reduce_learning_rate_interval):
"""Trains a deep LSTM model on the Tiny Shakespeare dataset."""
# Build the computation graph.
graph_tensors, dataset_train = build_graph(
lstm_depth=FLAGS.lstm_depth, batch_size=FLAGS.batch_size,
num_embedd... | python | def train(num_training_iterations, report_interval,
reduce_learning_rate_interval):
"""Trains a deep LSTM model on the Tiny Shakespeare dataset."""
# Build the computation graph.
graph_tensors, dataset_train = build_graph(
lstm_depth=FLAGS.lstm_depth, batch_size=FLAGS.batch_size,
num_embedd... | [
"def",
"train",
"(",
"num_training_iterations",
",",
"report_interval",
",",
"reduce_learning_rate_interval",
")",
":",
"# Build the computation graph.",
"graph_tensors",
",",
"dataset_train",
"=",
"build_graph",
"(",
"lstm_depth",
"=",
"FLAGS",
".",
"lstm_depth",
",",
... | Trains a deep LSTM model on the Tiny Shakespeare dataset. | [
"Trains",
"a",
"deep",
"LSTM",
"model",
"on",
"the",
"Tiny",
"Shakespeare",
"dataset",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L171-L223 | train | Trains a deep LSTM model on the Tiny Shakespeare dataset. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/rnn_shakespeare.py | TextModel._build | def _build(self, one_hot_input_sequence):
"""Builds the deep LSTM model sub-graph.
Args:
one_hot_input_sequence: A Tensor with the input sequence encoded as a
one-hot representation. Its dimensions should be `[truncation_length,
batch_size, output_size]`.
Returns:
Tuple of the ... | python | def _build(self, one_hot_input_sequence):
"""Builds the deep LSTM model sub-graph.
Args:
one_hot_input_sequence: A Tensor with the input sequence encoded as a
one-hot representation. Its dimensions should be `[truncation_length,
batch_size, output_size]`.
Returns:
Tuple of the ... | [
"def",
"_build",
"(",
"self",
",",
"one_hot_input_sequence",
")",
":",
"input_shape",
"=",
"one_hot_input_sequence",
".",
"get_shape",
"(",
")",
"batch_size",
"=",
"input_shape",
"[",
"1",
"]",
"batch_embed_module",
"=",
"snt",
".",
"BatchApply",
"(",
"self",
... | Builds the deep LSTM model sub-graph.
Args:
one_hot_input_sequence: A Tensor with the input sequence encoded as a
one-hot representation. Its dimensions should be `[truncation_length,
batch_size, output_size]`.
Returns:
Tuple of the Tensor of output logits for the batch, with dimen... | [
"Builds",
"the",
"deep",
"LSTM",
"model",
"sub",
"-",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L280-L320 | train | Builds the deep LSTM model sub - graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/examples/rnn_shakespeare.py | TextModel.generate_string | def generate_string(self, initial_logits, initial_state, sequence_length):
"""Builds sub-graph to generate a string, sampled from the model.
Args:
initial_logits: Starting logits to sample from.
initial_state: Starting state for the RNN core.
sequence_length: Number of characters to sample.
... | python | def generate_string(self, initial_logits, initial_state, sequence_length):
"""Builds sub-graph to generate a string, sampled from the model.
Args:
initial_logits: Starting logits to sample from.
initial_state: Starting state for the RNN core.
sequence_length: Number of characters to sample.
... | [
"def",
"generate_string",
"(",
"self",
",",
"initial_logits",
",",
"initial_state",
",",
"sequence_length",
")",
":",
"current_logits",
"=",
"initial_logits",
"current_state",
"=",
"initial_state",
"generated_letters",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"("... | Builds sub-graph to generate a string, sampled from the model.
Args:
initial_logits: Starting logits to sample from.
initial_state: Starting state for the RNN core.
sequence_length: Number of characters to sample.
Returns:
A Tensor of characters, with dimensions `[sequence_length, batc... | [
"Builds",
"sub",
"-",
"graph",
"to",
"generate",
"a",
"string",
"sampled",
"from",
"the",
"model",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/examples/rnn_shakespeare.py#L323-L354 | train | Builds a sub - graph to generate a string from the model. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/vqvae.py | VectorQuantizer._build | def _build(self, inputs, is_training):
"""Connects the module to some inputs.
Args:
inputs: Tensor, final dimension must be equal to embedding_dim. All other
leading dimensions will be flattened and treated as a large batch.
is_training: boolean, whether this connection is to training data.... | python | def _build(self, inputs, is_training):
"""Connects the module to some inputs.
Args:
inputs: Tensor, final dimension must be equal to embedding_dim. All other
leading dimensions will be flattened and treated as a large batch.
is_training: boolean, whether this connection is to training data.... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"is_training",
")",
":",
"# Assert last dimension is same as self._embedding_dim",
"input_shape",
"=",
"tf",
".",
"shape",
"(",
"inputs",
")",
"with",
"tf",
".",
"control_dependencies",
"(",
"[",
"tf",
".",
"Asse... | Connects the module to some inputs.
Args:
inputs: Tensor, final dimension must be equal to embedding_dim. All other
leading dimensions will be flattened and treated as a large batch.
is_training: boolean, whether this connection is to training data.
Returns:
dict containing the follo... | [
"Connects",
"the",
"module",
"to",
"some",
"inputs",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/vqvae.py#L66-L112 | train | Connects the module to some inputs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/nets/vqvae.py | VectorQuantizerEMA._build | def _build(self, inputs, is_training):
"""Connects the module to some inputs.
Args:
inputs: Tensor, final dimension must be equal to embedding_dim. All other
leading dimensions will be flattened and treated as a large batch.
is_training: boolean, whether this connection is to training data.... | python | def _build(self, inputs, is_training):
"""Connects the module to some inputs.
Args:
inputs: Tensor, final dimension must be equal to embedding_dim. All other
leading dimensions will be flattened and treated as a large batch.
is_training: boolean, whether this connection is to training data.... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
",",
"is_training",
")",
":",
"# Ensure that the weights are read fresh for each timestep, which otherwise",
"# would not be guaranteed in an RNN setup. Note that this relies on inputs",
"# having a data dependency with the output of the previous ... | Connects the module to some inputs.
Args:
inputs: Tensor, final dimension must be equal to embedding_dim. All other
leading dimensions will be flattened and treated as a large batch.
is_training: boolean, whether this connection is to training data. When
this is set to False, the intern... | [
"Connects",
"the",
"module",
"to",
"some",
"inputs",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/nets/vqvae.py#L181-L252 | train | Connects the module to some inputs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/pondering_rnn.py | _nested_add | def _nested_add(nested_a, nested_b):
"""Add two arbitrarily nested `Tensors`."""
return nest.map(lambda a, b: a + b, nested_a, nested_b) | python | def _nested_add(nested_a, nested_b):
"""Add two arbitrarily nested `Tensors`."""
return nest.map(lambda a, b: a + b, nested_a, nested_b) | [
"def",
"_nested_add",
"(",
"nested_a",
",",
"nested_b",
")",
":",
"return",
"nest",
".",
"map",
"(",
"lambda",
"a",
",",
"b",
":",
"a",
"+",
"b",
",",
"nested_a",
",",
"nested_b",
")"
] | Add two arbitrarily nested `Tensors`. | [
"Add",
"two",
"arbitrarily",
"nested",
"Tensors",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L33-L35 | train | Add two arbitrarily nested Tensors. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/pondering_rnn.py | _nested_unary_mul | def _nested_unary_mul(nested_a, p):
"""Multiply `Tensors` in arbitrarily nested `Tensor` `nested_a` with `p`."""
def mul_with_broadcast(tensor):
ndims = tensor.shape.ndims
if ndims != 2:
p_reshaped = tf.reshape(p, [-1] + [1] * (ndims - 1))
return p_reshaped * tensor
else:
return p * te... | python | def _nested_unary_mul(nested_a, p):
"""Multiply `Tensors` in arbitrarily nested `Tensor` `nested_a` with `p`."""
def mul_with_broadcast(tensor):
ndims = tensor.shape.ndims
if ndims != 2:
p_reshaped = tf.reshape(p, [-1] + [1] * (ndims - 1))
return p_reshaped * tensor
else:
return p * te... | [
"def",
"_nested_unary_mul",
"(",
"nested_a",
",",
"p",
")",
":",
"def",
"mul_with_broadcast",
"(",
"tensor",
")",
":",
"ndims",
"=",
"tensor",
".",
"shape",
".",
"ndims",
"if",
"ndims",
"!=",
"2",
":",
"p_reshaped",
"=",
"tf",
".",
"reshape",
"(",
"p",... | Multiply `Tensors` in arbitrarily nested `Tensor` `nested_a` with `p`. | [
"Multiply",
"Tensors",
"in",
"arbitrarily",
"nested",
"Tensor",
"nested_a",
"with",
"p",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L38-L47 | train | Multiply Tensors in arbitrarily nested Tensor nested_a with p. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/pondering_rnn.py | ACTCore._cond | def _cond(self, unused_x, unused_cumul_out, unused_prev_state,
unused_cumul_state, cumul_halting, unused_iteration,
unused_remainder):
"""The `cond` of the `tf.while_loop`."""
return tf.reduce_any(cumul_halting < 1) | python | def _cond(self, unused_x, unused_cumul_out, unused_prev_state,
unused_cumul_state, cumul_halting, unused_iteration,
unused_remainder):
"""The `cond` of the `tf.while_loop`."""
return tf.reduce_any(cumul_halting < 1) | [
"def",
"_cond",
"(",
"self",
",",
"unused_x",
",",
"unused_cumul_out",
",",
"unused_prev_state",
",",
"unused_cumul_state",
",",
"cumul_halting",
",",
"unused_iteration",
",",
"unused_remainder",
")",
":",
"return",
"tf",
".",
"reduce_any",
"(",
"cumul_halting",
"... | The `cond` of the `tf.while_loop`. | [
"The",
"cond",
"of",
"the",
"tf",
".",
"while_loop",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L132-L136 | train | The cond of the tf. while_loop. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/pondering_rnn.py | ACTCore._body | def _body(self, x, cumul_out, prev_state, cumul_state,
cumul_halting, iteration, remainder, halting_linear, x_ones):
"""The `body` of `tf.while_loop`."""
# Increase iteration count only for those elements that are still running.
all_ones = tf.constant(1, shape=(self._batch_size, 1), dtype=self._... | python | def _body(self, x, cumul_out, prev_state, cumul_state,
cumul_halting, iteration, remainder, halting_linear, x_ones):
"""The `body` of `tf.while_loop`."""
# Increase iteration count only for those elements that are still running.
all_ones = tf.constant(1, shape=(self._batch_size, 1), dtype=self._... | [
"def",
"_body",
"(",
"self",
",",
"x",
",",
"cumul_out",
",",
"prev_state",
",",
"cumul_state",
",",
"cumul_halting",
",",
"iteration",
",",
"remainder",
",",
"halting_linear",
",",
"x_ones",
")",
":",
"# Increase iteration count only for those elements that are still... | The `body` of `tf.while_loop`. | [
"The",
"body",
"of",
"tf",
".",
"while_loop",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L138-L164 | train | The body of the while loop. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/pondering_rnn.py | ACTCore._build | def _build(self, x, prev_state):
"""Connects the core to the graph.
Args:
x: Input `Tensor` of shape `(batch_size, input_size)`.
prev_state: Previous state. This could be a `Tensor`, or a tuple of
`Tensor`s.
Returns:
The tuple `(output, state)` for this core.
Raises:
... | python | def _build(self, x, prev_state):
"""Connects the core to the graph.
Args:
x: Input `Tensor` of shape `(batch_size, input_size)`.
prev_state: Previous state. This could be a `Tensor`, or a tuple of
`Tensor`s.
Returns:
The tuple `(output, state)` for this core.
Raises:
... | [
"def",
"_build",
"(",
"self",
",",
"x",
",",
"prev_state",
")",
":",
"x",
".",
"get_shape",
"(",
")",
".",
"with_rank",
"(",
"2",
")",
"self",
".",
"_batch_size",
"=",
"x",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
"[",
"0",
"]",
"s... | Connects the core to the graph.
Args:
x: Input `Tensor` of shape `(batch_size, input_size)`.
prev_state: Previous state. This could be a `Tensor`, or a tuple of
`Tensor`s.
Returns:
The tuple `(output, state)` for this core.
Raises:
ValueError: if the `Tensor` `x` does no... | [
"Connects",
"the",
"core",
"to",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/pondering_rnn.py#L166-L211 | train | Connects the core to the graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/custom_getters/restore_initializer.py | restore_initializer | def restore_initializer(filename, name_fn=None,
collection=tf.GraphKeys.GLOBAL_VARIABLES):
"""Custom getter to restore all variables with `snt.restore_initializer`.
Args:
filename: The filename of the checkpoint.
name_fn: A function which can map the name of the variable requested. ... | python | def restore_initializer(filename, name_fn=None,
collection=tf.GraphKeys.GLOBAL_VARIABLES):
"""Custom getter to restore all variables with `snt.restore_initializer`.
Args:
filename: The filename of the checkpoint.
name_fn: A function which can map the name of the variable requested. ... | [
"def",
"restore_initializer",
"(",
"filename",
",",
"name_fn",
"=",
"None",
",",
"collection",
"=",
"tf",
".",
"GraphKeys",
".",
"GLOBAL_VARIABLES",
")",
":",
"def",
"_restore_initializer",
"(",
"getter",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwar... | Custom getter to restore all variables with `snt.restore_initializer`.
Args:
filename: The filename of the checkpoint.
name_fn: A function which can map the name of the variable requested. This
allows restoring variables with values having different names in the
checkpoint.
collection: Only s... | [
"Custom",
"getter",
"to",
"restore",
"all",
"variables",
"with",
"snt",
".",
"restore_initializer",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/custom_getters/restore_initializer.py#L26-L75 | train | Custom getter to restore all variables with snt. restore_initializer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/embed.py | _embedding_dim | def _embedding_dim(vocab_size):
"""Calculate a reasonable embedding size for a vocabulary.
Rule of thumb is 6 * 4th root of vocab_size.
Args:
vocab_size: Size of the input vocabulary.
Returns:
The embedding size to use.
Raises:
ValueError: if `vocab_size` is invalid.
"""
if not vocab_size or... | python | def _embedding_dim(vocab_size):
"""Calculate a reasonable embedding size for a vocabulary.
Rule of thumb is 6 * 4th root of vocab_size.
Args:
vocab_size: Size of the input vocabulary.
Returns:
The embedding size to use.
Raises:
ValueError: if `vocab_size` is invalid.
"""
if not vocab_size or... | [
"def",
"_embedding_dim",
"(",
"vocab_size",
")",
":",
"if",
"not",
"vocab_size",
"or",
"(",
"vocab_size",
"<=",
"0",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid vocab_size %g.\"",
"%",
"vocab_size",
")",
"return",
"int",
"(",
"round",
"(",
"6.0",
"*",
... | Calculate a reasonable embedding size for a vocabulary.
Rule of thumb is 6 * 4th root of vocab_size.
Args:
vocab_size: Size of the input vocabulary.
Returns:
The embedding size to use.
Raises:
ValueError: if `vocab_size` is invalid. | [
"Calculate",
"a",
"reasonable",
"embedding",
"size",
"for",
"a",
"vocabulary",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/embed.py#L30-L44 | train | Calculate a reasonable embedding size for a vocabulary. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/embed.py | Embed._build | def _build(self, ids):
"""Lookup embeddings.
Looks up an embedding vector for each value in `ids`. All ids must be within
[0, vocab_size), else an `InvalidArgumentError` is raised at runtime.
Args:
ids: Tensor of dtype int64.
Returns:
Tensor of tf.shape(ids) + [embedding_dim] and dtyp... | python | def _build(self, ids):
"""Lookup embeddings.
Looks up an embedding vector for each value in `ids`. All ids must be within
[0, vocab_size), else an `InvalidArgumentError` is raised at runtime.
Args:
ids: Tensor of dtype int64.
Returns:
Tensor of tf.shape(ids) + [embedding_dim] and dtyp... | [
"def",
"_build",
"(",
"self",
",",
"ids",
")",
":",
"# Construct embeddings.",
"if",
"self",
".",
"_existing_vocab",
"is",
"None",
":",
"if",
"self",
".",
"EMBEDDINGS",
"not",
"in",
"self",
".",
"_initializers",
":",
"self",
".",
"_initializers",
"[",
"sel... | Lookup embeddings.
Looks up an embedding vector for each value in `ids`. All ids must be within
[0, vocab_size), else an `InvalidArgumentError` is raised at runtime.
Args:
ids: Tensor of dtype int64.
Returns:
Tensor of tf.shape(ids) + [embedding_dim] and dtype float32. | [
"Lookup",
"embeddings",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/embed.py#L139-L182 | train | Builds the lookup embeddings. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/spatial_transformer.py | _create_affine_features | def _create_affine_features(output_shape, source_shape):
"""Generates n-dimensional homogenous coordinates for a given grid definition.
`source_shape` and `output_shape` are used to define the size of the source
and output signal domains, as opposed to the shape of the respective
Tensors. For example, for an i... | python | def _create_affine_features(output_shape, source_shape):
"""Generates n-dimensional homogenous coordinates for a given grid definition.
`source_shape` and `output_shape` are used to define the size of the source
and output signal domains, as opposed to the shape of the respective
Tensors. For example, for an i... | [
"def",
"_create_affine_features",
"(",
"output_shape",
",",
"source_shape",
")",
":",
"ranges",
"=",
"[",
"np",
".",
"linspace",
"(",
"-",
"1",
",",
"1",
",",
"x",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"for",
"x",
"in",
"reversed",
"(",
"outp... | Generates n-dimensional homogenous coordinates for a given grid definition.
`source_shape` and `output_shape` are used to define the size of the source
and output signal domains, as opposed to the shape of the respective
Tensors. For example, for an image of size `width=W` and `height=H`,
`{source,output}_shap... | [
"Generates",
"n",
"-",
"dimensional",
"homogenous",
"coordinates",
"for",
"a",
"given",
"grid",
"definition",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L107-L147 | train | Generates n - dimensional homogenous coordinates for a given source and output grids. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/spatial_transformer.py | AffineGridWarper._create_features | def _create_features(self, constraints):
"""Creates all the matrices needed to compute the output warped grids."""
affine_warp_constraints = constraints
if not isinstance(affine_warp_constraints, AffineWarpConstraints):
affine_warp_constraints = AffineWarpConstraints(affine_warp_constraints)
mask ... | python | def _create_features(self, constraints):
"""Creates all the matrices needed to compute the output warped grids."""
affine_warp_constraints = constraints
if not isinstance(affine_warp_constraints, AffineWarpConstraints):
affine_warp_constraints = AffineWarpConstraints(affine_warp_constraints)
mask ... | [
"def",
"_create_features",
"(",
"self",
",",
"constraints",
")",
":",
"affine_warp_constraints",
"=",
"constraints",
"if",
"not",
"isinstance",
"(",
"affine_warp_constraints",
",",
"AffineWarpConstraints",
")",
":",
"affine_warp_constraints",
"=",
"AffineWarpConstraints",... | Creates all the matrices needed to compute the output warped grids. | [
"Creates",
"all",
"the",
"matrices",
"needed",
"to",
"compute",
"the",
"output",
"warped",
"grids",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L214-L272 | train | Creates all the matrices needed to compute the output warped grids. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/spatial_transformer.py | AffineGridWarper._build | def _build(self, inputs):
"""Assembles the module network and adds it to the graph.
The internal computation graph is assembled according to the set of
constraints provided at construction time.
Args:
inputs: Tensor containing a batch of transformation parameters.
Returns:
A batch of ... | python | def _build(self, inputs):
"""Assembles the module network and adds it to the graph.
The internal computation graph is assembled according to the set of
constraints provided at construction time.
Args:
inputs: Tensor containing a batch of transformation parameters.
Returns:
A batch of ... | [
"def",
"_build",
"(",
"self",
",",
"inputs",
")",
":",
"input_shape",
"=",
"tf",
".",
"shape",
"(",
"inputs",
")",
"input_dtype",
"=",
"inputs",
".",
"dtype",
".",
"as_numpy_dtype",
"batch_size",
"=",
"tf",
".",
"expand_dims",
"(",
"input_shape",
"[",
"0... | Assembles the module network and adds it to the graph.
The internal computation graph is assembled according to the set of
constraints provided at construction time.
Args:
inputs: Tensor containing a batch of transformation parameters.
Returns:
A batch of warped grids.
Raises:
... | [
"Assembles",
"the",
"module",
"network",
"and",
"adds",
"it",
"to",
"the",
"graph",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L274-L355 | train | Builds the internal module network. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/spatial_transformer.py | AffineGridWarper.inverse | def inverse(self, name=None):
"""Returns a `sonnet` module to compute inverse affine transforms.
The function first assembles a network that given the constraints of the
current AffineGridWarper and a set of input parameters, retrieves the
coefficients of the corresponding inverse affine transfor... | python | def inverse(self, name=None):
"""Returns a `sonnet` module to compute inverse affine transforms.
The function first assembles a network that given the constraints of the
current AffineGridWarper and a set of input parameters, retrieves the
coefficients of the corresponding inverse affine transfor... | [
"def",
"inverse",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"_num_coeff",
"!=",
"6",
":",
"raise",
"tf",
".",
"errors",
".",
"UnimplementedError",
"(",
"'AffineGridWarper currently supports'",
"'inversion only for the 2D case.'",
")",
"... | Returns a `sonnet` module to compute inverse affine transforms.
The function first assembles a network that given the constraints of the
current AffineGridWarper and a set of input parameters, retrieves the
coefficients of the corresponding inverse affine transform, then feeds its
output into a... | [
"Returns",
"a",
"sonnet",
"module",
"to",
"compute",
"inverse",
"affine",
"transforms",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L361-L458 | train | Returns a sonnet module that performs the inverse affine transformation of a reference set of points. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/sonnet | sonnet/python/modules/spatial_transformer.py | AffineWarpConstraints._calc_mask | def _calc_mask(self):
"""Computes a boolean mask from the user defined constraints."""
mask = []
for row in self._constraints:
mask.append(tuple(x is None for x in row))
return tuple(mask) | python | def _calc_mask(self):
"""Computes a boolean mask from the user defined constraints."""
mask = []
for row in self._constraints:
mask.append(tuple(x is None for x in row))
return tuple(mask) | [
"def",
"_calc_mask",
"(",
"self",
")",
":",
"mask",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
".",
"_constraints",
":",
"mask",
".",
"append",
"(",
"tuple",
"(",
"x",
"is",
"None",
"for",
"x",
"in",
"row",
")",
")",
"return",
"tuple",
"(",
"mask... | Computes a boolean mask from the user defined constraints. | [
"Computes",
"a",
"boolean",
"mask",
"from",
"the",
"user",
"defined",
"constraints",
"."
] | 00612ca3178964d86b556e062694d808ff81fcca | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/spatial_transformer.py#L495-L500 | train | Computes a boolean mask from the user defined constraints. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.