How to use the dnn.layers.Layers function in dnn

To help you get started, we’ve selected a few dnn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github harpribot / representation-music / dnn / layers.py View on Github external
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
github harpribot / representation-music / Models / model.py View on Github external
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)
github harpribot / representation-music / Models / model.py View on Github external
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