(self, model, input_record, max_score=0, bucket_boundaries=None,
hash_buckets=True, weight_optim=None, name="bucket_weighted")
| 21 | |
| 22 | class 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 |
nothing calls this directly
no test coverage detected