3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
6 from __future__
import unicode_literals
8 from caffe2.python
import core, schema
9 from caffe2.python.layers.layers
import (ModelLayer, LayerParameter)
10 from caffe2.python.layers.sampling_trainable_mixin
import SamplingTrainableMixin
24 name='fc_without_bias',
27 super(FCWithoutBias, self).__init__(model, name, input_record, **kwargs)
28 assert isinstance(input_record,
schema.Scalar),
"Incorrect input type" 29 assert len(input_record.field_types()[0].shape) > 0, (
30 "FCWithoutBias expects limited dimensions of the input tensor" 33 input_dims = input_record.field_types()[0].shape[0]
34 assert input_dims > 0, (
35 "FCWithoutBias expects input dimensions > 0, got {}".format(input_dims)
39 (np.float32, (output_dims, )),
40 model.net.NextScopedBlob(name +
'_output')
43 scale = math.sqrt(1.0 / input_dims)
44 weight_init = weight_init
if weight_init
else (
45 'UniformFill', {
'min': -scale,
49 self.
w = model.net.NextScopedBlob(name +
"_w")
57 shape=[output_dims, input_dims],
60 optimizer=weight_optim
64 def _add_ops(self, net, params):
71 def param_blobs(self):
def CreateOperator(operator_type, inputs, outputs, name='', control_input=None, device_option=None, arg=None, engine=None, kwargs)