Spaces:
Configuration error
Configuration error
Update utils.py
Browse files
utils.py
CHANGED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
|
4 |
+
|
5 |
+
def plot_accuracy(history):
|
6 |
+
plt.plot(history.history["accuracy"], label="train")
|
7 |
+
plt.plot(history.history["val_accuracy"], label="validation")
|
8 |
+
plt.legend()
|
9 |
+
plt.show()
|
10 |
+
|
11 |
+
|
12 |
+
def plot_loss(history):
|
13 |
+
plt.plot(history.history["loss"], label="train")
|
14 |
+
plt.plot(history.history["val_loss"], label="validation")
|
15 |
+
plt.legend()
|
16 |
+
plt.show()
|
17 |
+
|
18 |
+
|
19 |
+
def process(image, label):
|
20 |
+
image = tf.cast(image / 255.0, tf.float32)
|
21 |
+
return image, label
|