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

Method __init__

caffe2/python/layers/label_smooth.py:29–41  ·  view source on GitHub ↗
(
        self, model, label, smooth_matrix, name='label_smooth', **kwargs
    )

Source from the content-addressed store, hash-verified

27
28class LabelSmooth(ModelLayer):
29 def __init__(
30 self, model, label, smooth_matrix, name='label_smooth', **kwargs
31 ):
32 super().__init__(model, name, label, **kwargs)
33 self.label = label
34 # shape as a list
35 smooth_matrix = np.array(smooth_matrix).astype(np.float32).flatten()
36 self.set_dim(smooth_matrix)
37 self.set_smooth_matrix(smooth_matrix)
38 self.output_schema = schema.Scalar(
39 (np.float32, (self.dim, )),
40 self.get_next_blob_reference('smoothed_label')
41 )
42
43 def set_dim(self, smooth_matrix):
44 num_elements = smooth_matrix.size

Callers

nothing calls this directly

Calls 5

set_dimMethod · 0.95
set_smooth_matrixMethod · 0.95
astypeMethod · 0.80
flattenMethod · 0.45

Tested by

no test coverage detected