layers package

Submodules

layers.FC module

class layers.FC.FC(output_dim, input_dim=None, activation=None, weight_decay=None, ensemble_size=1)

Bases: object

Represents a fully-connected layer in a network.

Parameters:
  • output_dim – (int) The dimensionality of the output of this layer.
  • input_dim – (int/None) The dimensionality of the input of this layer.
  • activation – (str/None) The activation function applied on the outputs. See FC._activations to see the list of allowed strings. None applies the identity function.
  • weight_decay – (float) The rate of weight decay applied to the weights of this layer.
  • ensemble_size – (int) The number of networks in the ensemble within which this layer will be used.
compute_output_tensor(input_tensor)

Returns the resulting tensor when all operations of this layer are applied to input_tensor.

If input_tensor is 2D, this method returns a 3D tensor representing the output of each layer in the ensemble on the input_tensor. Otherwise, if the input_tensor is 3D, the output is also 3D, where output[i] = layer_ensemble[i](input[i]).

Parameters:input_tensor – (tf.Tensor) The input to the layer.

Returns: The output of the layer, as described above.

construct_vars()

Constructs the variables of this fully-connected layer.

Returns: None

copy(sess=None)

Returns a Layer object with the same parameters as this layer.

Parameters:
  • sess – (tf.Session/None) session containing the current values of the variables to be copied. Must be passed in to copy values.
  • copy_vals – (bool) Indicates whether variable values will be copied over. Ignored if the variables of this layer has not yet been constructed.

Returns: The copied layer.

get_activation(as_func=True)

Returns the current activation function for this layer.

Parameters:as_func – (bool) Determines whether the returned value is the string corresponding to the activation function or the activation function itself.

Returns: The activation function (string/function, see as_func argument for details).

get_decays()

Returns the list of losses corresponding to the weight decay imposed on each weight of the network.

Returns: the list of weight decay losses.

get_ensemble_size()

Returns the ensemble size.

Returns: int

get_input_dim()

Returns the dimension of the input.

Returns: The dimension of the input

get_output_dim()

Returns the dimension of the output.

Returns: The dimension of the output.

get_vars()

Returns the variables of this layer.

get_weight_decay()

Returns the current rate of weight decay set for this layer.

Returns: The weight decay rate.

set_activation(activation)

Sets the activation function for this layer.

Parameters:activation – (str) The activation function to be used.

Returns: None.

set_ensemble_size(ensemble_size)

Sets the ensemble size.

Parameters:ensemble_size (int) –

Returns: None

set_input_dim(input_dim)

Sets the dimension of the input.

Parameters:input_dim – (int) The dimension of the input.

Returns: None

set_output_dim(output_dim)

Sets the dimension of the output.

Parameters:output_dim – (int) The dimension of the output.

Returns: None.

set_weight_decay(weight_decay)

Sets the current weight decay rate for this layer.

Returns: None

unset_activation()

Removes the currently set activation function for this layer.

Returns: None

unset_weight_decay()

Removes weight decay from this layer.

Returns: None

Module contents