MCPcopy Create free account
hub / github.com/Kaggle/docker-python / test_tf_keras

Method test_tf_keras

tests/test_tensorflow.py:22–47  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

20 self.assertEqual(4, len(result.shape))
21
22 def test_tf_keras(self):
23 x_train = np.random.random((100, 28, 28))
24 y_train = np.random.randint(10, size=(100, 1))
25 x_test = np.random.random((20, 28, 28))
26 y_test = np.random.randint(10, size=(20, 1))
27
28 model = tf.keras.models.Sequential([
29 tf.keras.layers.Flatten(input_shape=(28, 28)),
30 tf.keras.layers.Dense(128, activation='relu'),
31 tf.keras.layers.Dropout(0.2),
32 tf.keras.layers.Dense(10, activation='softmax')
33 ])
34
35 model.compile(
36 optimizer='adam',
37 loss='sparse_categorical_crossentropy',
38 metrics=['accuracy'])
39
40 model.fit(x_train, y_train, epochs=1)
41
42 result = model.evaluate(x_test, y_test)
43 self.assertEqual(2, len(result))
44
45 # exercices pydot path.
46 tf.keras.utils.plot_model(model, to_file="tf_plot_model.png")
47 self.assertTrue(os.path.isfile("tf_plot_model.png"))
48
49 def test_lstm(self):
50 x_train = np.random.random((100, 28, 28))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected