コード例 #1
0
    def ChainLoss(self, input_feats, deriv_weights,
            indexs, in_labels, weights, statesinfo, num_states, frames,
            label_dim,
            den_indexs, den_in_labels, den_weights, den_statesinfo, den_num_states,
            den_start_state = 0 ,delete_laststatesuperfinal = True,
            l2_regularize = 0.00005, leaky_hmm_coefficient = 0.1, xent_regularize =0.025):
        seq_len = None
        last_output, rnn_keep_state_op, rnn_state_zero_op = self.CreateModel(
                input_feats, seq_len)

        # this function deriv_weights from time_major = False change major = True
        if self.time_major_cf:
            deriv_weights = tf.transpose(deriv_weights)

        if self.time_major_cf:
            last_output = last_output[-1 * frames[0]:]
        else:
            # now don't test 
            last_output = last_output[:][-1 * frames[0]:]

        with tf.name_scope('ChainLoss'):
            chain_loss = chainloss(last_output, deriv_weights,
                    indexs, in_labels, weights, statesinfo, num_states,
                    label_dim,
                    den_indexs, den_in_labels, den_weights, den_statesinfo, den_num_states,
                    den_start_state, delete_laststatesuperfinal,
                    l2_regularize, leaky_hmm_coefficient, xent_regularize, 
                    time_major = self.time_major_cf)

            total_frames = 0
            chain_mean_loss = chain_loss[0]/chain_loss[2]

        return chain_mean_loss, chain_loss, None, rnn_keep_state_op, rnn_state_zero_op
コード例 #2
0
def chainloss_fn(outputs,
                 deriv_weights,
                 indexs,
                 in_labels,
                 weights,
                 statesinfo,
                 num_states,
                 label_dim,
                 den_indexs,
                 den_in_labels,
                 den_weights,
                 den_statesinfo,
                 den_num_states,
                 den_start_state,
                 delete_laststatesuperfinal,
                 l2_regularize,
                 leaky_hmm_coefficient,
                 xent_regularize,
                 time_major=True):
    chain_loss = chainloss(outputs,
                           deriv_weights,
                           indexs,
                           in_labels,
                           weights,
                           statesinfo,
                           num_states,
                           label_dim,
                           den_indexs,
                           den_in_labels,
                           den_weights,
                           den_statesinfo,
                           den_num_states,
                           den_start_state,
                           delete_laststatesuperfinal,
                           l2_regularize,
                           leaky_hmm_coefficient,
                           xent_regularize,
                           time_major=True)
    return chain_loss
コード例 #3
0
            den_fst)
        den_indexs = np.reshape(den_indexs, [-1]).tolist()
        den_in_labels = np.reshape(den_in_labels, [-1]).tolist()
        den_weights = np.reshape(den_weights, [-1]).tolist()
        den_statesinfo = np.reshape(den_statesinfo, [-1]).tolist()

        chain_loss = chainloss(self_X,
                               self_Y,
                               self_indexs,
                               self_in_labels,
                               self_weights,
                               self_statesinfo,
                               self_num_states,
                               label_dim,
                               den_indexs,
                               den_in_labels,
                               den_weights,
                               den_statesinfo,
                               den_num_states,
                               den_start_state,
                               delete_laststatesuperfinal,
                               l2_regularize,
                               leaky_hmm_coefficient,
                               xent_regularize,
                               time_major=True)

        #outputs = np.random.rand(50* 64*3766).reshape(50, 64, 3766)

        sess = tf.Session()
        while True:
            start1 = time.time()