(self, smooth_matrix)
| 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: |
no test coverage detected