Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Last active March 25, 2018 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/8875107b9d571a4d5f55c815e1727ae3 to your computer and use it in GitHub Desktop.
Save NMZivkovic/8875107b9d571a4d5f55c815e1727ae3 to your computer and use it in GitHub Desktop.
import tensorflow as tf
from tensorflow.contrib import rnn
class RNNGenerator:
def create_LSTM(self, inputs, weights, biases, seq_size, num_units):
# Reshape input to [1, sequence_size] and split it into sequences
inputs = tf.reshape(inputs, [-1, seq_size])
inputs = tf.split(inputs, seq_size, 1)
# LSTM with 2 layers
rnn_model = rnn.MultiRNNCell([rnn.BasicLSTMCell(num_units),rnn.BasicLSTMCell(num_units)])
# Generate prediction
outputs, states = rnn.static_rnn(rnn_model, inputs, dtype=tf.float32)
return tf.matmul(outputs[-1], weights['out']) + biases['out']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment