From 758069e7d456ee93d52e7d4be411f93d5f7060f2 Mon Sep 17 00:00:00 2001 From: tpt5cu Date: Fri, 1 Feb 2019 15:40:54 -0500 Subject: [PATCH] changes numpy array dimensions Existing model is different than loaded model in the coursework. The array needs the addition: source = np.array(list(map(lambda x: to_categorical(x, num_classes=len(human_vocab)), source)), ndmin=3) to fix dimensional issues --- .../Neural machine translation with attention - v2.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sequence Models/Neural machine translation with attention - v2.ipynb b/Sequence Models/Neural machine translation with attention - v2.ipynb index 57c9c7e4..35736f89 100644 --- a/Sequence Models/Neural machine translation with attention - v2.ipynb +++ b/Sequence Models/Neural machine translation with attention - v2.ipynb @@ -866,7 +866,7 @@ "for example in EXAMPLES:\n", " \n", " source = string_to_int(example, Tx, human_vocab)\n", - " source = np.array(list(map(lambda x: to_categorical(x, num_classes=len(human_vocab)), source))).swapaxes(0,1)\n", + " source = np.array(list(map(lambda x: to_categorical(x, num_classes=len(human_vocab)), source)), ndmin=3)\n", " prediction = model.predict([source, s0, c0])\n", " prediction = np.argmax(prediction, axis = -1)\n", " output = [inv_machine_vocab[int(i)] for i in prediction]\n",