Exemplo n.º 1
0
 def filter(self):
     """Gets the filters. The dimensions:
     - BatchLength * BatchWidth * ListSize is filter_count
     - Height, Width, Depth are taken from filter_size
     - Channels is equal to the inputs' Channels
     """
     return Blob(self._internal.get_filter())
Exemplo n.º 2
0
    def weights(self):
        """Gets the trained weights as a blob of the dimensions:

        - **BatchLength** * **BatchWidth** * **ListSize** equal to element_count
        - **Height**, **Width**, **Depth**, **Channels** the same as for the first input
        """
        return Blob.Blob(self._internal.get_weights())
Exemplo n.º 3
0
 def get_embeddings(self, index):
     """Gets the representation table with the given index 
     as a blob of the dimensions:
     - BatchLength * BatchWidth * ListSize is dimensions[i].VectorCount
     - Height * Width * Depth * Channels is dimensions[i].VectorSize
     """
     return Blob.Blob(self._internal.get_embeddings(index))
Exemplo n.º 4
0
    def recurrent_weights(self):
        """Gets the FC_recur weights. The dimensions:

            - **BatchLength** * **BatchWidth** * **ListSize** is hidden_size
            - **Height** * **Width** * **Depth** * **Channels** is hidden_size
        """
        return Blob.Blob(self._internal.get_recurrent_weights())
Exemplo n.º 5
0
    def addends(self):
        """Gets the trainable vectors added. The blob dimensions:

            - BatchLength, BatchWidth are 1
            - the other dimensions are the same as for the input
        """
        return Blob.Blob(self._internal.get_addends())
Exemplo n.º 6
0
    def input_weights(self):
        """Gets the input weights matrix. The dimensions:

            - **BatchLength** * **BatchWidth** * **ListSize** is hidden_size
            - **Height** * **Width** * **Depth** * **Channels** is the same as for the input
        """
        return Blob.Blob(self._internal.get_input_weights())
Exemplo n.º 7
0
    def main_weights(self):
        """Gets the output weights as a 2d matrix of the size:

        - **BatchLength** * **BatchWidth** * **ListSize** equal to **hidden_size**
        - **Height** * **Width** * **Depth** * **Channels** equal to 
          this dimension of the input plus hidden_size
        """
        return Blob.Blob(self._internal.get_main_weights())
Exemplo n.º 8
0
    def filter(self):
        """Gets the filters. The dimensions:

        - **BatchLength** * **BatchWidth** * **ListSize** is filter_count
        - **Height**, **Width**, **Depth** are taken from filter_size
        - **Channels** is equal to the inputs' **Channels**
        """
        return Blob.Blob(self._internal.get_filter())
Exemplo n.º 9
0
 def filter(self):
     """Gets the filters. The dimensions:
     - BatchLength is 1
     - BatchWidth is filter_count
     - Height is filter_size
     - Width, Depth are 1
     - Channels is the inputs' Height * Width * Depth * Channels
     """
     return Blob(self._internal.get_filter())
Exemplo n.º 10
0
    def filter(self):
        """Gets the trained weights for each gate. The blob dimensions:

            - **BatchLength** is 1
            - **BatchWidth** is 3 * hidden_size
              (contains the weights for each of the three gates 
              in the order: update, forget, output)
            - **Height** is window_size
            - **Width**, **Depth** are 1
            - **Channels** is equal to the input's **Height** * **Width** * **Depth** * **Channels**
        """
        return Blob.Blob(self._internal.get_filter())
Exemplo n.º 11
0
def call_loss_calculator(data, labels, loss_calculator):
    """Calculates the value of specified custom loss function.
    
    :param neoml.Blob.Blob data: the network response.

    :param neoml.Blob.Blob labels: the correct labels.

    :param neoml.Dnn.CustomLossCalculatorBase loss_calculator: a user-implemented object
        that provides the method to calculate the custom loss.
    """
    data_blob = Blob.Blob(data)
    labels_blob = Blob.Blob(labels)

    loss = loss_calculator.calc(data_blob, labels_blob)

    if not type(loss) is Blob.Blob:
        raise ValueError("The result of 'calc' must be neoml.Blob.")

    if loss.size != data_blob.object_count:
        raise ValueError(
            "The result of 'calc' must have size == data.object_count.")

    return loss._internal
Exemplo n.º 12
0
 def input_weights(self):
     """Gets the input hidden layer weights.
     The blob size is (4*HiddenSize)x1x1xInputSize.
     """
     return Blob.Blob(self._internal.get_input_weights())
Exemplo n.º 13
0
 def get_blob(self):
     """Gets the data blob.
     """
     return Blob.Blob(self._internal.get_blob())
Exemplo n.º 14
0
 def main_free_term(self):
     """Gets the output free terms as a blob of total hidden_size size.
     """
     return Blob.Blob(self._internal.get_main_free_term())
Exemplo n.º 15
0
 def scale(self):
     """Gets scale, one of the trainable parameters in the formula.
     The total blob size is equal to the input **Height** * **Width** * **Depth** * **Channels**.
     """
     return Blob.Blob(self._internal.get_scale())
Exemplo n.º 16
0
 def free_term(self):
     """Gets the free term. The blob size is filter_count.
     """
     return Blob.Blob(self._internal.get_free_term())
Exemplo n.º 17
0
 def input_free_term(self):
     """Gets the FC_input free term, of hidden_size length.
     """
     return Blob.Blob(self._internal.get_input_free_term())
Exemplo n.º 18
0
 def recurrent_free_term(self):
     """Gets the recurrent free term.
     """
     return Blob.Blob(self._internal.get_recurrent_free_term())
Exemplo n.º 19
0
 def bias(self):
     """Gets the bias vector, of hidden_size length.
     """
     return Blob.Blob(self._internal.get_recurrent_weights())
Exemplo n.º 20
0
 def bias(self):
     """Gets bias, one of the trainable parameters in the formula.
     The total blob size is equal to the input Height * Width * Depth * Channels.
     """
     return Blob.Blob(self._internal.get_bias())
Exemplo n.º 21
0
 def get_blob(self):
     """Gets the blob with source data.
     """
     return Blob.Blob(self._internal.get_blob())
Exemplo n.º 22
0
 def free_term(self):
     """Gets the free term for all three gates in the same order.
     The blob size is 3 * hidden_size.
     """
     return Blob.Blob(self._internal.get_free_term())
Exemplo n.º 23
0
 def input_free_term(self):
     """Gets the input free term.
     """
     return Blob.Blob(self._internal.get_input_free_term())
Exemplo n.º 24
0
 def weights(self):
     """Gets the trained weights as a blob of the dimensions:
     - BatchLength * BatchWidth * ListSize equal to element_count
     - Height, Width, Depth, Channels the same as for the first input
     """
     return Blob.Blob(self._internal.get_weights())
Exemplo n.º 25
0
 def recurrent_weights(self):
     """Gets the recurrent hidden layer weights.
     The blob size is (4*HiddenSize)x1x1xHiddenSize.
     """
     return Blob.Blob(self._internal.get_recurrent_weights())
Exemplo n.º 26
0
 def free_term(self):
     """Gets the free term vector, of element_count length.
     """
     return Blob.Blob(self._internal.get_free_term())
Exemplo n.º 27
0
 def input_weights(self):
     """Gets the FC_input weights. The dimensions:
     - BatchLength * BatchWidth * ListSize is hidden_size
     - Height * Width * Depth * Channels is the same as for the input
     """
     return Blob.Blob(self._internal.get_input_weights())
Exemplo n.º 28
0
 def gate_free_term(self):
     """Gets the gate free terms as a blob of total 2 * hidden_size size.
     """
     return Blob.Blob(self._internal.get_gate_free_term())
Exemplo n.º 29
0
 def recurrent_free_term(self):
     """Gets the FC_recur free term, of hidden_size length.
     """
     return Blob.Blob(self._internal.get_recurrent_free_term())
Exemplo n.º 30
0
 def free_term(self):
     """Gets the free term. The blob size is inputs' Channels.
     """
     return Blob.Blob(self._internal.get_free_term())