Merge pull request #293 from ibeauregard/changes-chap16
(Chapter 16) A few edits in the notebookmain
commit
0a55f55372
|
@ -1407,7 +1407,7 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
"def string_to_ids(s, chars=POSSIBLE_CHARS):\n",
|
||||
" return [POSSIBLE_CHARS.index(c) for c in s]"
|
||||
" return [chars.index(c) for c in s]"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1476,7 +1476,7 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"What classes does it belong to?"
|
||||
"What class does it belong to?"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1623,7 +1623,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"INPUT_CHARS = \"\".join(sorted(set(\"\".join(MONTHS)))) + \"01234567890, \"\n",
|
||||
"INPUT_CHARS = \"\".join(sorted(set(\"\".join(MONTHS) + \"0123456789, \")))\n",
|
||||
"INPUT_CHARS"
|
||||
]
|
||||
},
|
||||
|
@ -2090,7 +2090,7 @@
|
|||
" len(INPUT_CHARS) + 1, encoder_embedding_size)(encoder_inputs)\n",
|
||||
"\n",
|
||||
"decoder_embedding_layer = keras.layers.Embedding(\n",
|
||||
" len(INPUT_CHARS) + 2, decoder_embedding_size)\n",
|
||||
" len(OUTPUT_CHARS) + 2, decoder_embedding_size)\n",
|
||||
"decoder_embeddings = decoder_embedding_layer(decoder_inputs)\n",
|
||||
"\n",
|
||||
"encoder = keras.layers.LSTM(units, return_state=True)\n",
|
||||
|
@ -2287,7 +2287,7 @@
|
|||
" len(INPUT_CHARS) + 1, encoder_embedding_size)(encoder_inputs)\n",
|
||||
"\n",
|
||||
"decoder_embedding_layer = keras.layers.Embedding(\n",
|
||||
" len(INPUT_CHARS) + 2, decoder_embedding_size)\n",
|
||||
" len(OUTPUT_CHARS) + 2, decoder_embedding_size)\n",
|
||||
"decoder_embeddings = decoder_embedding_layer(decoder_inputs)\n",
|
||||
"\n",
|
||||
"encoder = keras.layers.LSTM(units, return_state=True)\n",
|
||||
|
@ -2615,6 +2615,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install -q -U transformers\n",
|
||||
"from transformers import TFOpenAIGPTLMHeadModel\n",
|
||||
"\n",
|
||||
"model = TFOpenAIGPTLMHeadModel.from_pretrained(\"openai-gpt\")"
|
||||
|
|
Loading…
Reference in New Issue