Skip to content

Commit 5ac82cb

Browse files
committed
bug fixing for lab 1
1 parent bddee0c commit 5ac82cb

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

lab1/Part1_TensorFlow.ipynb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377
" return y\n",
378378
"\n",
379379
"# Since layer parameters are initialized randomly, we will set a random seed for reproducibility\n",
380-
"tf.random.set_seed(1)\n",
380+
"tf.keras.utils.set_random_seed(1)\n",
381381
"layer = OurDenseLayer(3)\n",
382382
"layer.build((1,2))\n",
383383
"x_input = tf.constant([[1,2.]], shape=(1,2))\n",
@@ -707,7 +707,17 @@
707707
},
708708
"kernelspec": {
709709
"display_name": "Python 3",
710+
"language": "python",
710711
"name": "python3"
712+
},
713+
"language_info": {
714+
"name": "python",
715+
"version": "3.9.6"
716+
},
717+
"vscode": {
718+
"interpreter": {
719+
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
720+
}
711721
}
712722
},
713723
"nbformat": 4,

lab1/solutions/Part1_TensorFlow_Solution.ipynb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@
383383
" return y\n",
384384
"\n",
385385
"# Since layer parameters are initialized randomly, we will set a random seed for reproducibility\n",
386-
"tf.random.set_seed(1)\n",
386+
"tf.keras.utils.set_random_seed(1)\n",
387387
"layer = OurDenseLayer(3)\n",
388388
"layer.build((1,2))\n",
389389
"x_input = tf.constant([[1,2.]], shape=(1,2))\n",
@@ -725,7 +725,17 @@
725725
},
726726
"kernelspec": {
727727
"display_name": "Python 3",
728+
"language": "python",
728729
"name": "python3"
730+
},
731+
"language_info": {
732+
"name": "python",
733+
"version": "3.9.6"
734+
},
735+
"vscode": {
736+
"interpreter": {
737+
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
738+
}
729739
}
730740
},
731741
"nbformat": 4,

mitdeeplearning/lab1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def test_batch_func_next_step(func, args):
8080
return True
8181

8282
def test_custom_dense_layer_output(y):
83-
true_y = np.array([[0.2697859, 0.45750418, 0.66536945]],dtype='float32')
83+
true_y = np.array([[0.27064407 0.1826951 0.50374055]],dtype='float32')
8484
assert tf.shape(y).numpy().tolist() == list(true_y.shape), "[FAIL] output is of incorrect shape. expected {} but got {}".format(true_y.shape, y.numpy().shape)
85-
np.testing.assert_almost_equal(y.numpy(), true_y, decimal=7, err_msg="[FAIL] output is of incorrect value. expected {} but got {}".format(y.numpy(), true_y), verbose=True)
85+
np.testing.assert_almost_equal(y.numpy(), true_y, decimal=7, err_msg="[FAIL] output is of incorrect value. expected {} but got {}".format(true_y, y.numpy()), verbose=True)
8686
print("[PASS] test_custom_dense_layer_output")
8787
return True

0 commit comments

Comments
 (0)