Пример #1
0
 def __init__(self, network):
     super(NetWithLossClass, self).__init__(auto_prefix=False)
     self.loss = P.CTCLoss(ctc_merge_repeated=True)
     self.network = network
     self.ReduceMean_false = P.ReduceMean(keep_dims=False)
     self.squeeze_op = P.Squeeze(0)
     self.cast_op = P.Cast()
Пример #2
0
    def __init__(self):
        super(ctc_loss, self).__init__()

        self.loss = P.CTCLoss(preprocess_collapse_repeated=False,
                              ctc_merge_repeated=True,
                              ignore_longer_outputs_than_inputs=False)

        self.mean = P.ReduceMean()
        self.transpose = P.Transpose()
        self.reshape = P.Reshape()
Пример #3
0
 def __init__(self, max_sequence_length, max_label_length, batch_size):
     super(CTCLoss, self).__init__()
     self.sequence_length = Parameter(Tensor(np.array([max_sequence_length] * batch_size), mstype.int32),
                                      name="sequence_length")
     labels_indices = []
     for i in range(batch_size):
         for j in range(max_label_length):
             labels_indices.append([i, j])
     self.labels_indices = Parameter(Tensor(np.array(labels_indices), mstype.int64), name="labels_indices")
     self.reshape = P.Reshape()
     self.ctc_loss = P.CTCLoss(ctc_merge_repeated=True)
Пример #4
0
 def __init__(self):
     super(Net, self).__init__()
     self.ctc_loss = P.CTCLoss()
Пример #5
0
     'desc_bprop': [3, 3],
     'skip': ['backward']}),
 ('ApplyRMSProp', {
     'block': P.ApplyRMSProp(),
     'desc_const': [0.9, 0.0, 1e-10, 0.001],
     'desc_inputs': [[3, 3], [3, 3], [3, 3], [3, 3]],
     'desc_bprop': [3, 3],
     'skip': ['backward']}),
 ('ApplyCenteredRMSProp', {
     'block': P.ApplyCenteredRMSProp(),
     'desc_const': [0.9, 0.0, 1e-10, 0.001],
     'desc_inputs': [[3, 3], [3, 3], [3, 3], [3, 3], [3, 3]],
     'desc_bprop': [3, 3],
     'skip': ['backward']}),
 ('CTCLoss', {
     'block': P.CTCLoss(),
     'desc_inputs': [Tensor(np.ones([6, 4, 6]).astype(np.float32)),
                     Tensor(np.array([[0, 1], [1, 0], [2, 3], [3, 2]]).astype(np.int64)),
                     Tensor(np.array([1, 2, 3, 4]).astype(np.int32)),
                     Tensor(np.array([6, 6, 6, 6]).astype(np.int32))],
     'desc_bprop': [[4], [6, 4, 6]]}),
 ('L2Loss_1', {
     'block': P.L2Loss(),
     'desc_inputs': [Tensor(np.array([1, 2, 3, 4]), mstype.float32)],
     'desc_bprop': []}),
 ('L2Loss_2', {
     'block': P.L2Loss(),
     'desc_inputs': [Tensor(np.array([[1, 1], [2, 2], [3, 3], [4, 4]]), mstype.float16)],
     'desc_bprop': []}),
 ('ResizeBilinear', {
     'block': P.ResizeBilinear((5, 5)),
Пример #6
0
 def __init__(self):
     super(Net, self).__init__()
     self.loss = P.CTCLoss()
     self.div = P.RealDiv()
     self.mean = P.ReduceMean()