Caffe2 - Python API
A deep learning, cross platform ML framework
Public Member Functions | Public Attributes | List of all members
caffe2.python.layers.concat.Concat Class Reference
Inheritance diagram for caffe2.python.layers.concat.Concat:

Public Member Functions

def __init__ (self, model, input_record, axis=1, add_axis=0, name='concat', kwargs)
 
def add_ops (self, net)
 

Public Attributes

 axis
 
 add_axis
 
 output_schema
 

Detailed Description

Construct Concat layer
Assume that first dimension is batch,

Example:

    embedding_dim = 64
    input_record = self.new_record(schema.Struct(
        ('input1', schema.Scalar((np.float32, (embedding_dim, )))),
        ('input2', schema.Scalar((np.float32, (embedding_dim, )))),
        ('input3', schema.Scalar((np.float32, (embedding_dim, )))),
    ))

    output = self.model.Concat(input_record)
    self.assertEqual(
        schema.Scalar((np.float32, ((len(input_record.fields) * embedding_dim, )))),
        output
    )

    # Note that in Concat layer we assume first dimension is batch.
    # so input is B * embedding_dim
    # add_axis=1 make it B * 1 * embedding_dim
    # Concat on axis=1 make it B * N * embedding_dim

    output = self.model.Concat(input_record, axis=1, add_axis=1)
    self.assertEqual(
        schema.Scalar((np.float32, ((len(input_record.fields), embedding_dim)))),
        output
    )

Definition at line 35 of file concat.py.


The documentation for this class was generated from the following file: