

{"id":15108,"date":"2018-05-18T08:22:37","date_gmt":"2018-05-18T08:22:37","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=15108"},"modified":"2021-05-14T11:00:23","modified_gmt":"2021-05-14T05:30:23","slug":"tensorflow-recurrent-neural-network","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/","title":{"rendered":"Recurrent Neural Network TensorFlow | LSTM Neural Network"},"content":{"rendered":"<p><span style=\"font-weight: 400\">In our previous <strong>TensorFlow<\/strong> tutorial we&#8217;ve already seen how to build a <strong>convolutional neural network<\/strong> using TensorFlow. Today, we will see <em>TensorFlow Recurrent Neural Network<\/em>. In this TensorFlow RNN Tutorial, we\u2019ll be learning how to build a TensorFlow Recurrent Neural Network (RNN).<\/span><\/p>\n<p><span style=\"font-weight: 400\"> Moreover, we will discuss language modeling and how to prepare data for RNN TensorFlow. Along with Recurrent Neural Network in TensorFlow, we are also going to study TensorFlow LSTM. Also, we will see how to run the code in\u00a0Recurrent Neural Network in TensorFlow.<\/span><\/p>\n<p>So, let&#8217;s start the TensorFlow Recurrent Neural Network.<\/p>\n<h2><span style=\"font-weight: 400\">Recurrent Neural Network in TensorFlow<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Persistence is a quality that makes humans different from machines. Persistence in the sense that you never start thinking from scratch. You use your previous memory to understand your current learning. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Traditional neural networks do not possess this quality and this shortcoming is overcome using TensorFlow RNN (Recurrent Neural Network).<\/span><\/p>\n<div id=\"attachment_15113\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/RNN-unrolled.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15113\" class=\"wp-image-15113 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/RNN-unrolled.png\" alt=\"Recurrent Neural Network Tensoflow - What is RNN\" width=\"1200\" height=\"492\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/RNN-unrolled.png 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/RNN-unrolled-150x62.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/RNN-unrolled-300x123.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/RNN-unrolled-768x315.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/RNN-unrolled-1024x420.png 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-15113\" class=\"wp-caption-text\">Recurrent Neural Network Tensoflow &#8211; What is RNN<\/p><\/div>\n<h2><span style=\"font-weight: 400\">RNN Language Modelling<\/span><\/h2>\n<p><span style=\"font-weight: 400\">In this TensorFlow Recurrent Neural Network tutorial, you will learn how to train a recurrent neural network on a task of language modeling. The goal of the problem is to fit a model which assigns probabilities to sentences.<\/span><\/p>\n<p><span style=\"font-weight: 400\"> It does so, by predicting next words in a text given a history of previous words. For this purpose, we will use the\u00a0Penn TreeBank\u00a0(PTB) dataset, which is a popular benchmark and is small and relatively fast to train.<\/span><\/p>\n<p><span style=\"font-weight: 400\">You can solve language modeling problems such as <strong>speech recognition<\/strong>, machine translation, or image captioning using TensorFlow Recurrent Neural Network (RNN).<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Files Needed for Recurrent Neural Network<\/span><\/h2>\n<p><span style=\"font-weight: 400\">From the github repository of TensorFLow, download the files from <\/span><strong>models\/tutorials\/rnn\/ptb containing ptb_world_lm.py and reader.py.<\/strong><\/p>\n<h2><span style=\"font-weight: 400\">Preparing the Data<\/span><\/h2>\n<p><span style=\"font-weight: 400\">The data required for TensorFlow Recurrent Neural Network (RNN) is in the<\/span><span style=\"font-weight: 400\">\u00a0<\/span><span style=\"font-weight: 400\">data\/<\/span><span style=\"font-weight: 400\">\u00a0<\/span><span style=\"font-weight: 400\">directory of the\u00a0<\/span><a href=\"http:\/\/www.fit.vutbr.cz\/~imikolov\/rnnlm\/simple-examples.tgz\"><span style=\"font-weight: 400\">PTB dataset from Tomas Mikolov&#8217;s webpage<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The dataset is already preprocessed and containing an overall of 10000 different words, including the end-of-sentence marker and a special symbol (\\&lt;unk&gt;) for rare words. <\/span><\/p>\n<p><span style=\"font-weight: 400\">In\u00a0<\/span><span style=\"font-weight: 400\">reader.py<\/span><span style=\"font-weight: 400\">, you will convert each word to a unique integer identifier, in order to make it easy for the neural network to process the data.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">LSTM (Long Short-Term Memory) Network<\/span><\/h2>\n<p><span style=\"font-weight: 400\">The core of the RNN model consists of an LSTM cell that processes one word at a time and computes probabilities of the possible values for the next word in the sentence. The memory state of the network is initialized with a vector of zeros and is updated after reading each word. <\/span><\/p>\n<p><span style=\"font-weight: 400\">For computational reasons, you can process data in mini-batches of size\u00a0<\/span><i><span style=\"font-weight: 400\">batch_size<\/span><\/i><span style=\"font-weight: 400\">. Every word in a batch should correspond to a time t. The <strong>machine learning<\/strong> library will automatically sum the gradients of each batch for you.<\/span><\/p>\n<div id=\"attachment_15114\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM3-chain.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15114\" class=\"wp-image-15114 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM3-chain.png\" alt=\"Long Short Term Neural Network\" width=\"1200\" height=\"492\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM3-chain.png 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM3-chain-150x62.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM3-chain-300x123.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM3-chain-768x315.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM3-chain-1024x420.png 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-15114\" class=\"wp-caption-text\">Working of Long Short-Term Neural Network<\/p><\/div>\n<div id=\"attachment_15115\" style=\"width: 960px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM2-notation.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15115\" class=\"wp-image-15115 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM2-notation.png\" alt=\"Long Short-Term Neural Network\" width=\"950\" height=\"177\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM2-notation.png 950w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM2-notation-150x28.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM2-notation-300x56.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/LSTM2-notation-768x143.png 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/a><p id=\"caption-attachment-15115\" class=\"wp-caption-text\">Long Short-Term Neural Network<\/p><\/div>\n<pre class=\"EnlighterJSRAW\"> t=0  t=1    t=2  t=3     t=4\r\n[The, brown, fox, is,     quick]\r\n[The, red,   fox, jumped, high]\r\nwords_in_dataset[0] = [The, The]\r\nwords_in_dataset[1] = [brown, red]\r\nwords_in_dataset[2] = [fox, fox]\r\nwords_in_dataset[3] = [is, jumped]\r\nwords_in_dataset[4] = [quick, high]\r\nbatch_size = 2, time_steps = 5<\/pre>\n<p><strong>The basic pseudocode:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">words_in_dataset = tf.placeholder(tf.float32, [time_steps, batch_size, num_features])\r\nlstm = tf.contrib.rnn.BasicLSTMCell(lstm_size)\r\n# Initial state of the LSTM memory.\r\nhidden_state = tf.zeros([batch_size, lstm.state_size])\r\ncurrent_state = tf.zeros([batch_size, lstm.state_size])\r\nstate = hidden_state, current_state\r\nprobabilities = []\r\nloss = 0.0\r\nfor current_batch_of_words in words_in_dataset:\r\n    # The value of state is updated after processing each batch of words.\r\n    output, state = lstm(current_batch_of_words, state)\r\n    # The LSTM output can be used to make next word predictions\r\n    logits = tf.matmul(output, softmax_w) + softmax_b\r\n    probabilities.append(tf.nn.softmax(logits))\r\n    loss += loss_function(probabilities, target_words)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h3>a. Shortened Backpropagation<\/h3>\n<p><span style=\"font-weight: 400\">By design, the output of a recurrent neural network (RNN) depends on arbitrarily distant inputs. Unfortunately, this makes backpropagation computation difficult. <\/span><\/p>\n<p><span style=\"font-weight: 400\">In order to make the learning process tractable, it is common practice to create an &#8220;unrolled&#8221; version of the network, which contains a fixed number (<\/span><span style=\"font-weight: 400\">num_steps<\/span><span style=\"font-weight: 400\">) of LSTM inputs and outputs. The model is then trained on this finite approximation of the RNN. <\/span><\/p>\n<p><span style=\"font-weight: 400\">This can be implemented by feeding inputs of length\u00a0<\/span><span style=\"font-weight: 400\">num_steps<\/span><span style=\"font-weight: 400\">\u00a0at a time and be performing a backward pass after each such input block.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The following code creates a graph which performs a shortened backpropagation:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\"># Placeholder for the inputs in a given iteration.\r\nwords = tf.placeholder(tf.int32, [batch_size, num_steps])\r\nlstm = tf.contrib.rnn.BasicLSTMCell(lstm_size)\r\n# Initial state of the LSTM memory.\r\ninitial_state = state = tf.zeros([batch_size, lstm.state_size])\r\nfor i in range(num_steps):\r\n    # The value of state is updated after processing each batch of words.\r\n    output, state = lstm(words[:, i], state)\r\n    # The rest of the code.\r\n    # ...\r\nfinal_state = state<\/pre>\n<p><span style=\"font-weight: 400\">Performing an iteration over the whole dataset in Recurrent Neural Network TensorFlow<\/span><span style=\"font-weight: 400\">:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\"># A numpy array holding the state of LSTM after each batch of words.\r\nnumpy_state = initial_state.eval()\r\ntotal_loss = 0.0\r\nfor current_batch_of_words in words_in_dataset:\r\n    numpy_state, current_loss = session.run([final_state, loss],\r\n        # Initialize the LSTM state from the previous iteration.\r\n        feed_dict={initial_state: numpy_state, words: current_batch_of_words})\r\n    total_loss += current_loss\r\n<\/pre>\n<h3>b. Inputs<\/h3>\n<p><span style=\"font-weight: 400\">The word identities will be embedded into a dense representation (<strong>Word2Vec<\/strong>) before feeding to the<em> LSTM<\/em>. This allows the model to efficiently represent the knowledge about particular words and can be written as:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\"># embedding_matrix is a tensor of shape [vocabulary_size, embedding size]\r\nword_embeddings = tf.nn.embedding_lookup(embedding_matrix, word_ids)<\/pre>\n<p><span style=\"font-weight: 400\">The embedding matrix will be initialized randomly and the model will learn to differentiate the meaning of words just by looking at the data<\/span><span style=\"font-weight: 400\">.<\/span><\/p>\n<h3><span style=\"font-weight: 400\">c. Cost Function<\/span><\/h3>\n<p><span style=\"font-weight: 400\">We want to minimize the average negative log probability of the target words<\/span><span style=\"font-weight: 400\">:<\/span><\/p>\n<div id=\"attachment_15116\" style=\"width: 233px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-1-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15116\" class=\"wp-image-15116 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-1-1.png\" alt=\"TensorFlow recurrent Neural Network\" width=\"223\" height=\"73\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-1-1.png 223w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-1-1-150x49.png 150w\" sizes=\"auto, (max-width: 223px) 100vw, 223px\" \/><\/a><p id=\"caption-attachment-15116\" class=\"wp-caption-text\">Cost Function<\/p><\/div>\n<p><span style=\"font-weight: 400\">It is easy to implement but the function\u00a0<\/span><i><span style=\"font-weight: 400\">sequence_loss_by_example<\/span><\/i><span style=\"font-weight: 400\">\u00a0is already available, so you can use it.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The average per-word perplexity is equal to<\/span><\/p>\n<div id=\"attachment_15117\" style=\"width: 216px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captur6845e.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15117\" class=\"wp-image-15117 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captur6845e.png\" alt=\"Long Short Term Neural Network\" width=\"206\" height=\"53\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captur6845e.png 206w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captur6845e-150x39.png 150w\" sizes=\"auto, (max-width: 206px) 100vw, 206px\" \/><\/a><p id=\"caption-attachment-15117\" class=\"wp-caption-text\">LSTM- Average per-word<\/p><\/div>\n<p><span style=\"font-weight: 400\">You need to monitor this value throughout the training process<\/span><span style=\"font-weight: 400\">.<\/span><\/p>\n<h3><span style=\"font-weight: 400\">d. Stacking the Memories (LSTMs)<\/span><\/h3>\n<p><span style=\"font-weight: 400\">To give the model more expressive power, we can add multiple layers of LSTMs to process the data. The output of the first layer will become the input of the second and so on.<\/span><\/p>\n<p><span style=\"font-weight: 400\">We have a class called\u00a0<\/span><strong>MultiRNNCell<\/strong><span style=\"font-weight: 400\">\u00a0that makes the implementation smooth<\/span><span style=\"font-weight: 400\">:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">def lstm_cell():\r\n  return tf.contrib.rnn.BasicLSTMCell(lstm_size)\r\nstacked_lstm = tf.contrib.rnn.MultiRNNCell(\r\n    [lstm_cell() for _ in range(number_of_layers)])\r\ninitial_state = state = stacked_lstm.zero_state(batch_size, tf.float32)\r\nfor i in range(num_steps):\r\n    # The value of state is updated after processing each batch of words.\r\n    output, state = stacked_lstm(words[:, i], state)\r\n    # The rest of the code.\r\n    # ...\r\nfinal_state = state<\/pre>\n<h2><span style=\"font-weight: 400\">Running the Code in RNN<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Before running the code in Recurrent Neural Network in TensorFlow, make sure to download the PTB dataset, as discussed at the beginning of this tutorial. Then, extract the PTB dataset in your home directory as follows:<\/span><\/p>\n<p><strong>tar xvfz simple-examples.tgz -C $HOME<\/strong><\/p>\n<p><span style=\"font-weight: 400\"><strong>Note:<\/strong>\u00a0For Windows users, it might be a little different.<\/span><br \/>\n<span style=\"font-weight: 400\">Now, clone the\u00a0repository from github and run the following commands<\/span><span style=\"font-weight: 400\">:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">cd models\/tutorials\/rnn\/ptb\r\npython ptb_word_lm.py --data_path=$HOME\/simple-examples\/data\/ --model=small<\/pre>\n<p><span style=\"font-weight: 400\">There are 3 supported model configurations in the tutorial code: &#8220;small&#8221;, &#8220;medium&#8221; and &#8220;large&#8221;. The difference between them is in the size of the LSTMs and the set of hyperparameters used for training.<\/span><br \/>\n<span style=\"font-weight: 400\">The larger the model, the better results it should get.<\/span><\/p>\n<p>So, this was all about TensorFlow Recurrent Neural Network. Hope you like our explanation.<\/p>\n<h2><span style=\"font-weight: 400\">Conclusion<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Hence, in this Recurrent Neural Network TensorFlow tutorial, we saw that recurrent neural networks are a great way of building models with LSTMs and there are a number of ways through which you can make your model better such as decreasing the learning rate schedule and adding dropouts between LSTM layers. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Moreover, we discussed the process of language modeling and preparation of data for RNN TensorFlow. Along with this, we also saw what is RNN in TensorFlow. <\/span><\/p>\n<p><span style=\"font-weight: 400\">In addition, we discussed how can we run code for RNN TensorFlow. Furthermore, for any query regarding TensorFlow RNN, feel free to ask in the comment section.<\/span><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1942,&quot;href&quot;:&quot;http:\\\/\\\/www.fit.vutbr.cz\\\/~imikolov\\\/rnnlm\\\/simple-examples.tgz&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20220808164623\\\/https:\\\/\\\/www.fit.vutbr.cz\\\/~imikolov\\\/rnnlm\\\/simple-examples.tgz&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 12:39:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-15 13:08:27&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2025-12-25 01:38:26&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-08 03:11:26&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-12 07:36:14&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-17 10:33:20&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-03-13 02:07:37&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-03-22 17:53:10&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-03-26 21:21:36&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-10 16:49:10&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-29 08:50:09&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-05-13 10:08:11&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-06-17 18:06:00&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-29 22:05:27&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-29 22:05:27&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our previous TensorFlow tutorial we&#8217;ve already seen how to build a convolutional neural network using TensorFlow. Today, we will see TensorFlow Recurrent Neural Network. In this TensorFlow RNN Tutorial, we\u2019ll be learning how&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":22168,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[8422,8423,9052,10236,11434,11435,11436,11437,11438,11613,11614,15898,15904,15905],"class_list":["post-15108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tensorflow","tag-lstm","tag-lstm-neural-network","tag-neural-network","tag-ptb-dataset","tag-recurrent-neural-network","tag-recurrent-neural-network-in-tensorflow","tag-recurrent-neural-network-lstm","tag-recurrent-neural-network-tensorflow","tag-recurrent-neural-network-using-tensorflow","tag-rnn","tag-rnn-example","tag-what-is-recurrent-neural-network","tag-what-is-rnn","tag-what-is-rnn-in-tensorflow"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Recurrent Neural Network TensorFlow | LSTM Neural Network - DataFlair<\/title>\n<meta name=\"description\" content=\"Tensorflow Recurrent Neural Network,Long short-term memory network(LSTM), running code in RNN, what is RNN,RNN example,Rnn in Tensorflow,Tensorflow tutorial\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Recurrent Neural Network TensorFlow | LSTM Neural Network - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Tensorflow Recurrent Neural Network,Long short-term memory network(LSTM), running code in RNN, what is RNN,RNN example,Rnn in Tensorflow,Tensorflow tutorial\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-18T08:22:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-14T05:30:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Recurrent-Neural-Network.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Recurrent Neural Network TensorFlow | LSTM Neural Network - DataFlair","description":"Tensorflow Recurrent Neural Network,Long short-term memory network(LSTM), running code in RNN, what is RNN,RNN example,Rnn in Tensorflow,Tensorflow tutorial","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/","og_locale":"en_US","og_type":"article","og_title":"Recurrent Neural Network TensorFlow | LSTM Neural Network - DataFlair","og_description":"Tensorflow Recurrent Neural Network,Long short-term memory network(LSTM), running code in RNN, what is RNN,RNN example,Rnn in Tensorflow,Tensorflow tutorial","og_url":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-18T08:22:37+00:00","article_modified_time":"2021-05-14T05:30:23+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Recurrent-Neural-Network.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"Recurrent Neural Network TensorFlow | LSTM Neural Network","datePublished":"2018-05-18T08:22:37+00:00","dateModified":"2021-05-14T05:30:23+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/"},"wordCount":1033,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Recurrent-Neural-Network.jpg","keywords":["LSTM","lstm neural network","Neural network","PTB dataset","Recurrent neural network","Recurrent Neural Network in TensorFlow","recurrent neural network lstm","recurrent neural network TensorFlow","Recurrent Neural Network using TensorFlow","RNN","RNN example","What is Recurrent Neural Network","What is RNN","what is rnn in tensorflow"],"articleSection":["Tensorflow Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/","url":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/","name":"Recurrent Neural Network TensorFlow | LSTM Neural Network - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Recurrent-Neural-Network.jpg","datePublished":"2018-05-18T08:22:37+00:00","dateModified":"2021-05-14T05:30:23+00:00","description":"Tensorflow Recurrent Neural Network,Long short-term memory network(LSTM), running code in RNN, what is RNN,RNN example,Rnn in Tensorflow,Tensorflow tutorial","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Recurrent-Neural-Network.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Recurrent-Neural-Network.jpg","width":1200,"height":628,"caption":"Recurrent Neural Network TensorFlow | LSTM Neural Network"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-recurrent-neural-network\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Tensorflow Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/tensorflow\/"},{"@type":"ListItem","position":3,"name":"Recurrent Neural Network TensorFlow | LSTM Neural Network"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=15108"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15108\/revisions"}],"predecessor-version":[{"id":94996,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15108\/revisions\/94996"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/22168"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=15108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=15108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=15108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}