Tensorflow LSTM内存使用

Tensorflow LSTM内存使用,tensorflow,lstm,Tensorflow,Lstm,我正在尝试LSTM序列标签。在添加嵌入层之前,我将输入数据直接放入LSTM层。但它给我的GPU内存错误,即使批量大小是1 max_length是330,我应该改变模型还是添加嵌入层才行?我使用的是带有12GB内存的Titan X GPU # tf Graph input x = tf.placeholder(tf.float32, [None, max_length, num_table]) y = tf.placeholder(tf.float32, [None, max_length, n_

我正在尝试
LSTM
序列标签。在添加嵌入层之前,我将输入数据直接放入
LSTM
层。但它给我的GPU内存错误,即使批量大小是1

max_length
是330,我应该改变模型还是添加嵌入层才行?我使用的是带有12GB内存的Titan X GPU

# tf Graph input
x = tf.placeholder(tf.float32, [None, max_length, num_table])
y = tf.placeholder(tf.float32, [None, max_length, n_classes])
seqlen = tf.placeholder(tf.int32,[None])

# Define weights
weights = {
    'out': tf.Variable(tf.random_normal([n_hidden, n_classes]))
}
biases = {
    'out': tf.Variable(tf.random_normal([n_classes]))
}

def LSTM(x, seqlen, weights, biases):
    # given input: (batch_size, n_step, feature_table )
    # required : (n_step, batch_size, feature_table )
    x = tf.unpack(tf.transpose(x,perm=[1,0,2]))

    lstm_cell = tf.nn.rnn_cell.LSTMCell(n_hidden)
    #lstm_cell = tf.nn.rnn_cell.DropoutWrapper(lstm_cell,keep_prob)

    outputs, states = tf.nn.rnn(cell=lstm_cell,
        dtype=tf.float32,
        sequence_length=seqlen,
        inputs=x)

    # convert to (n_step, batch_size, n_classes)    
    temp = [tf.matmul(output,weights['out']) + biases['out'] for output in outputs]

    # convert to (batch_size, n_step, n_classes)
    temp = tf.transpose(tf.pack(temp),perm = [1,0,2])
    return temp

有多少类?
n_类
只有2个,但
num_表
相当大,大约50000个是从源代码构建的?你能检查什么进入和离开吗?实际上,你可以设置
tf.logging.verbosity(1)
,并查看带有
\uuuu LOG\u MEMORY\uuuu
的消息。有多少个类?
n\u classes
只有2个,但是
num\u table
相当大,你是从源代码构建的吗?你能检查什么进入和离开吗?实际上,你可以设置
tf.logging.verbosity(1)
,并查看带有
\uu LOG\u内存的消息。