Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add_hidden_layer(self, input_layer_id, input_width, output_width,
layer_name, batch_norm=False, sharing=False):
"""
Adds the hidden layer to the model
:param input_layer_id: The input layer identifier
:param input_width: The width of the input for this layer
:param output_width: The width of the output for this layer
:param layer_name: The name of the layer. Type=string
:param batch_norm: True -> if next layer is a batch normalization layer, else False. Default= False
:param sharing: True, if the layer is shared, else False.. Default=False
:return: None
"""
layer_id = self._get_layer_id(layer_name)
scope = Layers._get_scope(layer_name, layer_id, sharing)
with tf.variable_scope(scope):
assert self._layer_verifier(layer_id), 'Invalid: This layer is already present.'
reuse = sharing and (not self.is_first)
with tf.variable_scope("hello", reuse=reuse):
weights = weight_variable([input_width, output_width], "weight")
biases = bias_variable([output_width], "bias")
if batch_norm:
self.layers[layer_id] = tf.matmul(self.layers[input_layer_id], weights)
else:
self.layers[layer_id] = tf.matmul(self.layers[input_layer_id], weights) + biases
return layer_id
def __init__(self, task_ids, input_dimension, output_dimensions):
"""
The model class
:param task_ids: Dictionary of task identifiers-loss type pairs indexed by task-id.
:param input_dimension: Input dimension
:param output_dimensions: Dictionary of output dimensions indexed by task identifiers
"""
self.task_ids = task_ids
self.input_dimension = input_dimension
self.output_dimensions = output_dimensions
self.input_id = 'input'
Layers.__init__(self)
from abc import abstractmethod
from dnn.layers import Layers
class Model(Layers):
def __init__(self, task_ids, input_dimension, output_dimensions):
"""
The model class
:param task_ids: Dictionary of task identifiers-loss type pairs indexed by task-id.
:param input_dimension: Input dimension
:param output_dimensions: Dictionary of output dimensions indexed by task identifiers
"""
self.task_ids = task_ids
self.input_dimension = input_dimension
self.output_dimensions = output_dimensions
self.input_id = 'input'
Layers.__init__(self)
@abstractmethod