tensorflow rnn 最简单实现代码

tensorflow rnn 最简单实现代码


#!/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/

posted on 2017-08-06 09:15  TensorFlowNews  阅读(2232)  评论(0编辑  收藏  举报

TensorFlow

TensorFlow

磐创AI

TensorFlow 教程从入门到精通

TensorFlow 安装教程

Keras 从入门到精通

粒子群优化算法

聊天机器人

自然语言处理

TensorFlow

TensorFlow