MCPcopy Create free account
hub / github.com/pytorch/pytorch / __init__

Method __init__

caffe2/python/layers/fc_with_bootstrap.py:23–170  ·  view source on GitHub ↗
(
        self,
        model,
        input_record,
        output_dims,
        num_bootstrap,
        weight_init=None,
        bias_init=None,
        weight_optim=None,
        bias_optim=None,
        name="fc_with_bootstrap",
        weight_reg=None,
        bias_reg=None,
        clip_param=None,
        axis=1,
        **kwargs
    )

Source from the content-addressed store, hash-verified

21
22class FCWithBootstrap(SamplingTrainableMixin, ModelLayer):
23 def __init__(
24 self,
25 model,
26 input_record,
27 output_dims,
28 num_bootstrap,
29 weight_init=None,
30 bias_init=None,
31 weight_optim=None,
32 bias_optim=None,
33 name="fc_with_bootstrap",
34 weight_reg=None,
35 bias_reg=None,
36 clip_param=None,
37 axis=1,
38 **kwargs
39 ):
40 super().__init__(model, name, input_record, **kwargs)
41 assert isinstance(
42 input_record, schema.Scalar
43 ), "Incorrect input type {}".format(input_record)
44 assert (
45 len(input_record.field_types()[0].shape) > 0
46 ), "FC expects limited dimensions of the input tensor"
47 assert axis >= 1, "axis {} should >= 1.".format(axis)
48 self.axis = axis
49 input_dims = np.prod(input_record.field_types()[0].shape[axis - 1 :])
50
51 assert input_dims > 0, "FC expects input dimensions > 0, got {}".format(
52 input_dims
53 )
54
55 self.clip_args = None
56
57 # attributes for bootstrapping below
58 self.num_bootstrap = num_bootstrap
59
60 # input dim shape
61 self.input_dims = input_dims
62
63 # bootstrapped fully-connected layers to be used in eval time
64 self.bootstrapped_FCs = []
65
66 # scalar containing batch_size blob so that we don't need to recompute
67 self.batch_size = None
68
69 # we want this to be the last FC, so the output_dim should be 1, set to None
70 self.output_dim_vec = None
71
72 # lower bound when creating random indices
73 self.lower_bound = None
74
75 # upper bound when creating random indices
76 self.upper_bound = None
77
78 if clip_param is not None:
79 assert len(clip_param) == 2, (
80 "clip_param must be a tuple / list "

Callers

nothing calls this directly

Calls 10

isinstanceFunction · 0.85
listFunction · 0.85
rangeFunction · 0.50
formatMethod · 0.45
field_typesMethod · 0.45
prodMethod · 0.45
sqrtMethod · 0.45
extendMethod · 0.45
create_paramMethod · 0.45

Tested by

no test coverage detected