Merge pull request #2 from M21han/patch-2

Update Week 3 Programming Assignment.ipynb
This commit is contained in:
Priyatham Sai Chand 2021-08-09 06:14:26 +05:30 committed by GitHub
commit efa04b5ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -845,12 +845,15 @@
" # I couldn't get this one right. Let me know if you figured it out.\n",
" if initial_state is None:\n",
" model.layers[1].reset_states()\n",
" #Below code is right\n"
" else:\n",
" initial_state = model.layers[1].states\n",
" model.layers[1].reset_states(states=initial_state)\n",
" \n",
" prediction = model.predict(token_sequence)\n",
" token_sequence = np.array(token_sequence)\n"
" predicted = model.predict(token_sequence)\n"
" pred = np.expand_dims(predicted[0,-1,:],0)\n",
" \n",
" return prediction[0]"
" return pred"
]
},
{
@ -916,10 +919,8 @@
" distribution and return the sample as a single integer.\n",
" \"\"\"\n",
" # I couldn't get this one right. Let me know if you figured it out.\n",
" sample = tf.random.categorical(logits,1)\n",
" sampe = tf.squeeze(sample,axis = -1)\n",
" \n",
" return sample[0]"
" # Below code is right
" return int(tf.random.categorical(logits,1))"
]
},
{