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

Method set_smooth_matrix

caffe2/python/layers/label_smooth.py:52–65  ·  view source on GitHub ↗
(self, smooth_matrix)

Source from the content-addressed store, hash-verified

50 self.dim = int(np.sqrt(num_elements))
51
52 def set_smooth_matrix(self, smooth_matrix):
53 if not self.binary_prob_label:
54 self.smooth_matrix = self.model.add_global_constant(
55 '%s_label_smooth_matrix' % self.name,
56 array=smooth_matrix.reshape((self.dim, self.dim)),
57 dtype=np.dtype(np.float32),
58 )
59 self.len = self.model.add_global_constant(
60 '%s_label_dim' % self.name,
61 array=self.dim,
62 dtype=np.dtype(np.int64),
63 )
64 else:
65 self.smooth_matrix = smooth_matrix
66
67 def add_ops_for_binary_prob_label(self, net):
68 if self.label.field_type().base != np.float32:

Callers 1

__init__Method · 0.95

Calls 3

add_global_constantMethod · 0.80
reshapeMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected