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

Method __init__

caffe2/python/layers/bucket_weighted.py:23–48  ·  view source on GitHub ↗
(self, model, input_record, max_score=0, bucket_boundaries=None,
                 hash_buckets=True, weight_optim=None, name="bucket_weighted")

Source from the content-addressed store, hash-verified

21
22class BucketWeighted(ModelLayer):
23 def __init__(self, model, input_record, max_score=0, bucket_boundaries=None,
24 hash_buckets=True, weight_optim=None, name="bucket_weighted"):
25 super().__init__(model, name, input_record)
26
27 assert isinstance(input_record, schema.List), "Incorrect input type"
28 self.bucket_boundaries = bucket_boundaries
29 self.hash_buckets = hash_buckets
30 if bucket_boundaries is not None:
31 self.shape = len(bucket_boundaries) + 1
32 elif max_score > 0:
33 self.shape = max_score
34 else:
35 self.shape = get_categorical_limit(input_record)
36
37 self.bucket_w = self.create_param(param_name='bucket_w',
38 shape=[self.shape, ],
39 initializer=('ConstantFill', {'value': 1.0}),
40 optimizer=weight_optim)
41
42 self.output_schema = schema.Struct(
43 ('bucket_weights',
44 schema.Scalar((np.float32, self.shape),
45 self.get_next_blob_reference("bucket_w_gather")))
46 )
47
48 self.tags.update({Tags.HANDLE_AS_SPARSE_LAYER})
49
50 def get_memory_usage(self):
51 return self.shape

Callers

nothing calls this directly

Calls 5

get_categorical_limitFunction · 0.90
isinstanceFunction · 0.85
create_paramMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected