Advertisement

Tensorflow的常见模型(包括LSTM和BiLSTM)

阅读量:

LSTM模型应用与分析

复制代码
 import tensorflow as tf

    
 import tensorflow.contrib as contrib
    
 from tensorflow.python.ops import array_ops
    
  
    
 class lstm(object):
    
     def __init__(self, in_data, hidden_dim, batch_seqlen=None, flag='concat'):
    
     self.in_data = in_data
    
     self.hidden_dim = hidden_dim
    
     self.batch_seqlen = batch_seqlen
    
     self.flag = flag
    
     
    
     lstm_cell = contrib.rnn.LSTMCell(self.hidden_dim)
    
     out, _ = tf.nn.dynamic_rnn(cell=lstm_cell, inputs=self.in_data, sequence_length=self.batch_seqlen,dtype=tf.float32)

全部评论 (0)

还没有任何评论哟~