Update Week 3 Programming Assignment.ipynb

Now the code is right
This commit is contained in:
M21han 2020-10-11 20:38:43 +05:30 committed by GitHub
parent 84482561a2
commit 54b86019b7
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", " # I couldn't get this one right. Let me know if you figured it out.\n",
" if initial_state is None:\n", " if initial_state is None:\n",
" model.layers[1].reset_states()\n", " model.layers[1].reset_states()\n",
" #Below code is right\n"
" else:\n", " else:\n",
" initial_state = model.layers[1].states\n", " model.layers[1].reset_states(states=initial_state)\n",
" \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", " \n",
" return prediction[0]" " return pred"
] ]
}, },
{ {
@ -916,10 +919,8 @@
" distribution and return the sample as a single integer.\n", " distribution and return the sample as a single integer.\n",
" \"\"\"\n", " \"\"\"\n",
" # I couldn't get this one right. Let me know if you figured it out.\n", " # I couldn't get this one right. Let me know if you figured it out.\n",
" sample = tf.random.categorical(logits,1)\n", " # Below code is right
" sampe = tf.squeeze(sample,axis = -1)\n", " return int(tf.random.categorical(logits,1))"
" \n",
" return sample[0]"
] ]
}, },
{ {