因为现在的 example 都比较复杂涉及东西比较多,抽出来一个极简版本。


#!/usr/bin/env python
# -*- coding: utf-8 -*-


import tensorflow as tf
from tensorflow.contrib import rnn

import numpy as np

x=tf.placeholder(dtype=tf.float64,shape=[10,10,10],name="x")

train_x = np.ones(shape=[10, 10, 10], dtype=float)


cell=tf.nn.rnn_cell.BasicLSTMCell(10)


unstack_x = tf.unstack(x, 10, 1)

lstm_cell = rnn.BasicLSTMCell(10, forget_bias=1.0)

outputs, states = rnn.static_rnn(lstm_cell, unstack_x, dtype=tf.float64)

with tf.Session() as sess:
	sess.run(tf.global_variables_initializer())
	outputs_array=(sess.run(outputs,feed_dict={x:train_x}))



更多教程:http://www.tensorflownews.com/

相关文章:

  • 2021-10-09
  • 2021-10-04
  • 2021-04-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-11-30
猜你喜欢
  • 2021-11-03
  • 2021-08-26
  • 2022-02-12
  • 2021-05-14
  • 2022-02-09
  • 2021-07-02
相关资源
相似解决方案