from drig.networks.networks import TinyVGG
from drig.utils import plot_training_metrics, visualize_network, display_image
from keras.optimizers import SGD
from sklearn.metrics import classification_report
from keras.datasets import cifar10
from sklearn.model_selection import train_test_split
import numpy as np
from keras.preprocessing.image import ImageDataGenerator
import os
from sklearn.preprocessing import LabelBinarizer
import cv2
model_path=os.path.abspath(os.path.join(os.path.pardir,"models/ensemble_models/"))
((train_x, train_y),(test_x,test_y))=cifar10.load_data()
train_x=train_x.astype("float")/255.0
test_x=test_x.astype("float")/255.0
label_binarizer=LabelBinarizer()
train_y=label_binarizer.fit_transform(train_y)
test_y=label_binarizer.transform(test_y)
classes=["airplane","automobile","bird","cat","deer","dog","frog","horse","ship","truck"]
data_augementer=ImageDataGenerator(rotation_range=10,width_shift_range=0.1,height_shift_range=0.1,horizontal_flip=True,fill_mode="nearest")
number_of_ensemble_models=5
for i in range(0,number_of_ensemble_models):
epochs=60
batch_size=64
print(f"---------TRAINING {i+1} TINYVGG ON CIFAR10--------")
print(f"--------BUILDING MODEL------------")
model=TinyVGG.build(width=32,height=32,depth=3,classes=len(classes))
lr=0.01
decay=lr/epochs
optimizer=SGD(learning_rate=lr, decay=decay, momentum=0.9, nesterov=True)
print(f"--------COMPILING MODEL-----------")
model.compile(loss="categorical_crossentropy", optimizer=optimizer, metrics=["accuracy"])
step_size=len(train_x)//batch_size
print(f"--------TRAINING MODEL-----------")
Z=model.fit(data_augementer.flow(train_x,train_y,batch_size=batch_size), validation_data=(test_x,test_y),
epochs=epochs, steps_per_epoch=step_size,verbose=1)
model.save(f"{model_path}/tiny_vgg_{i+1}.model")
######
print(f"--------RUNNING PREDICTIONS------")
predictions=model.predict(test_x,batch_size=batch_size)
report=classification_report(test_y.argmax(axis=1),predictions.argmax(axis=1), target_names=classes)
report_file=open(f"{model_path}/tiny_vgg_{i+1}.txt", mode="w")
report_file.write(report)
report_file.close()
plot_training_metrics(epochs,Z,f"{model_path}/tiny_vgg_{i+1}.png")
---------TRAINING 1 TINYVGG ON CIFAR10-------- --------BUILDING MODEL------------ --------COMPILING MODEL----------- --------TRAINING MODEL----------- Epoch 1/60 781/781 [==============================] - 28s 35ms/step - loss: 2.1536 - accuracy: 0.3227 - val_loss: 1.3097 - val_accuracy: 0.5252 Epoch 2/60 781/781 [==============================] - 27s 35ms/step - loss: 1.5579 - accuracy: 0.4601 - val_loss: 1.2178 - val_accuracy: 0.5623 Epoch 3/60 781/781 [==============================] - 27s 35ms/step - loss: 1.3888 - accuracy: 0.5163 - val_loss: 1.2914 - val_accuracy: 0.5479 Epoch 4/60 781/781 [==============================] - 27s 35ms/step - loss: 1.2737 - accuracy: 0.5547 - val_loss: 1.2404 - val_accuracy: 0.5793 Epoch 5/60 781/781 [==============================] - 27s 35ms/step - loss: 1.1933 - accuracy: 0.5797 - val_loss: 1.1727 - val_accuracy: 0.6092 Epoch 6/60 781/781 [==============================] - 27s 35ms/step - loss: 1.1244 - accuracy: 0.6037 - val_loss: 1.0938 - val_accuracy: 0.6339 Epoch 7/60 781/781 [==============================] - 28s 35ms/step - loss: 1.0869 - accuracy: 0.6213 - val_loss: 0.9722 - val_accuracy: 0.6733 Epoch 8/60 781/781 [==============================] - 27s 35ms/step - loss: 1.0428 - accuracy: 0.6307 - val_loss: 1.0171 - val_accuracy: 0.6535 Epoch 9/60 781/781 [==============================] - 27s 35ms/step - loss: 1.0197 - accuracy: 0.6417 - val_loss: 1.0744 - val_accuracy: 0.6505 Epoch 10/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9963 - accuracy: 0.6479 - val_loss: 0.9545 - val_accuracy: 0.6756 Epoch 11/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9728 - accuracy: 0.6569 - val_loss: 1.0129 - val_accuracy: 0.6657 Epoch 12/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9541 - accuracy: 0.6633 - val_loss: 0.9043 - val_accuracy: 0.6904 Epoch 13/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9434 - accuracy: 0.6680 - val_loss: 1.0690 - val_accuracy: 0.6491 Epoch 14/60 781/781 [==============================] - 28s 35ms/step - loss: 0.9278 - accuracy: 0.6737 - val_loss: 0.9395 - val_accuracy: 0.6874 Epoch 15/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8931 - accuracy: 0.6836 - val_loss: 0.8758 - val_accuracy: 0.7025 Epoch 16/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8970 - accuracy: 0.6798 - val_loss: 1.2228 - val_accuracy: 0.6234 Epoch 17/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8860 - accuracy: 0.6867 - val_loss: 0.9606 - val_accuracy: 0.6752 Epoch 18/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8794 - accuracy: 0.6893 - val_loss: 0.9045 - val_accuracy: 0.6936 Epoch 19/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8642 - accuracy: 0.6959 - val_loss: 0.9462 - val_accuracy: 0.6843 Epoch 20/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8578 - accuracy: 0.7017 - val_loss: 0.8813 - val_accuracy: 0.6999 Epoch 21/60 781/781 [==============================] - 29s 37ms/step - loss: 0.8459 - accuracy: 0.7009 - val_loss: 0.8190 - val_accuracy: 0.7231 Epoch 22/60 781/781 [==============================] - 29s 37ms/step - loss: 0.8489 - accuracy: 0.7003 - val_loss: 0.8051 - val_accuracy: 0.7229 Epoch 23/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8362 - accuracy: 0.7042 - val_loss: 0.9462 - val_accuracy: 0.6876 Epoch 24/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8287 - accuracy: 0.7088 - val_loss: 0.8141 - val_accuracy: 0.7206 Epoch 25/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8308 - accuracy: 0.7088 - val_loss: 0.8190 - val_accuracy: 0.7215 Epoch 26/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8177 - accuracy: 0.7093 - val_loss: 0.8492 - val_accuracy: 0.7109 Epoch 27/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8003 - accuracy: 0.7228 - val_loss: 0.8622 - val_accuracy: 0.7034 Epoch 28/60 781/781 [==============================] - 30s 38ms/step - loss: 0.8042 - accuracy: 0.7174 - val_loss: 0.8138 - val_accuracy: 0.7218 Epoch 29/60 781/781 [==============================] - 29s 38ms/step - loss: 0.7957 - accuracy: 0.7191 - val_loss: 0.8221 - val_accuracy: 0.7196 Epoch 30/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7924 - accuracy: 0.7212 - val_loss: 0.7861 - val_accuracy: 0.7275 Epoch 31/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7787 - accuracy: 0.7266 - val_loss: 0.7614 - val_accuracy: 0.7387 Epoch 32/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7825 - accuracy: 0.7236 - val_loss: 0.7788 - val_accuracy: 0.7335 Epoch 33/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7788 - accuracy: 0.7252 - val_loss: 0.7841 - val_accuracy: 0.7299 Epoch 34/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7736 - accuracy: 0.7301 - val_loss: 0.7184 - val_accuracy: 0.7502 Epoch 35/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7698 - accuracy: 0.7272 - val_loss: 0.7712 - val_accuracy: 0.7379 Epoch 36/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7700 - accuracy: 0.7304 - val_loss: 0.7692 - val_accuracy: 0.7374 Epoch 37/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7638 - accuracy: 0.7329 - val_loss: 0.7376 - val_accuracy: 0.7453 Epoch 38/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7544 - accuracy: 0.7320 - val_loss: 0.8039 - val_accuracy: 0.7280 Epoch 39/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7618 - accuracy: 0.7321 - val_loss: 0.7207 - val_accuracy: 0.7526 Epoch 40/60 781/781 [==============================] - 30s 38ms/step - loss: 0.7544 - accuracy: 0.7348 - val_loss: 0.7925 - val_accuracy: 0.7307 Epoch 41/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7442 - accuracy: 0.7367 - val_loss: 0.7591 - val_accuracy: 0.7397 Epoch 42/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7502 - accuracy: 0.7365 - val_loss: 0.7479 - val_accuracy: 0.7454 Epoch 43/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7485 - accuracy: 0.7324 - val_loss: 0.8150 - val_accuracy: 0.7231 Epoch 44/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7508 - accuracy: 0.7402 - val_loss: 0.7438 - val_accuracy: 0.7451 Epoch 45/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7423 - accuracy: 0.7373 - val_loss: 0.7147 - val_accuracy: 0.7556 Epoch 46/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7356 - accuracy: 0.7428 - val_loss: 0.7660 - val_accuracy: 0.7391 Epoch 47/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7410 - accuracy: 0.7399 - val_loss: 0.8059 - val_accuracy: 0.7296 Epoch 48/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7354 - accuracy: 0.7444 - val_loss: 0.7912 - val_accuracy: 0.7326 Epoch 49/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7319 - accuracy: 0.7446 - val_loss: 0.7478 - val_accuracy: 0.7433 Epoch 50/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7292 - accuracy: 0.7408 - val_loss: 0.7864 - val_accuracy: 0.7376 Epoch 51/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7299 - accuracy: 0.7442 - val_loss: 0.7917 - val_accuracy: 0.7341 Epoch 52/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7311 - accuracy: 0.7446 - val_loss: 0.7147 - val_accuracy: 0.7546 Epoch 53/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7190 - accuracy: 0.7463 - val_loss: 0.8035 - val_accuracy: 0.7319 Epoch 54/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7104 - accuracy: 0.7529 - val_loss: 0.7405 - val_accuracy: 0.7466 Epoch 55/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7193 - accuracy: 0.7482 - val_loss: 0.7868 - val_accuracy: 0.7309 Epoch 56/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7221 - accuracy: 0.7456 - val_loss: 0.7569 - val_accuracy: 0.7469 Epoch 57/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7070 - accuracy: 0.7551 - val_loss: 0.7660 - val_accuracy: 0.7419 Epoch 58/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7186 - accuracy: 0.7478 - val_loss: 0.7444 - val_accuracy: 0.7472 Epoch 59/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7116 - accuracy: 0.7494 - val_loss: 0.6731 - val_accuracy: 0.7669 Epoch 60/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7078 - accuracy: 0.7524 - val_loss: 0.7800 - val_accuracy: 0.7364
/Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:2325: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`Model.state_updates` will be removed in a future version. ' /Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1397: UserWarning: `layer.updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`layer.updates` will be removed in a future version. '
WARNING:tensorflow:FOR KERAS USERS: The object that you are saving contains one or more Keras models or layers. If you are loading the SavedModel with `tf.keras.models.load_model`, continue reading (otherwise, you may ignore the following instructions). Please change your code to save with `tf.keras.models.save_model` or `model.save`, and confirm that the file "keras.metadata" exists in the export directory. In the future, Keras will only load the SavedModels that have this file. In other words, `tf.saved_model.save` will no longer write SavedModels that can be recovered as Keras models (this will apply in TF 2.5). FOR DEVS: If you are overwriting _tracking_metadata in your class, this property has been used to save metadata in the SavedModel. The metadta field will be deprecated soon, so please move the metadata to a different file. INFO:tensorflow:Assets written to: /Users/suyashsrivastava/drig/models/ensemble_models/tiny_vgg_1.model/assets --------RUNNING PREDICTIONS------
/Users/suyashsrivastava/drig/utils.py:46: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. plt.show()
---------TRAINING 2 TINYVGG ON CIFAR10-------- --------BUILDING MODEL------------ --------COMPILING MODEL----------- --------TRAINING MODEL----------- Epoch 1/60 781/781 [==============================] - 30s 38ms/step - loss: 2.1622 - accuracy: 0.3180 - val_loss: 1.5175 - val_accuracy: 0.4640 Epoch 2/60 781/781 [==============================] - 29s 37ms/step - loss: 1.5341 - accuracy: 0.4661 - val_loss: 1.2855 - val_accuracy: 0.5524 Epoch 3/60 781/781 [==============================] - 28s 35ms/step - loss: 1.3671 - accuracy: 0.5247 - val_loss: 1.1874 - val_accuracy: 0.5896 Epoch 4/60 781/781 [==============================] - 28s 35ms/step - loss: 1.2569 - accuracy: 0.5610 - val_loss: 1.2752 - val_accuracy: 0.5837 Epoch 5/60 781/781 [==============================] - 30s 38ms/step - loss: 1.1870 - accuracy: 0.5820 - val_loss: 1.2066 - val_accuracy: 0.5969 Epoch 6/60 781/781 [==============================] - 34s 44ms/step - loss: 1.1477 - accuracy: 0.5959 - val_loss: 1.0675 - val_accuracy: 0.6441 Epoch 7/60 781/781 [==============================] - 35s 45ms/step - loss: 1.0934 - accuracy: 0.6162 - val_loss: 1.1195 - val_accuracy: 0.6264 Epoch 8/60 781/781 [==============================] - 32s 41ms/step - loss: 1.0557 - accuracy: 0.6264 - val_loss: 1.0156 - val_accuracy: 0.6574 Epoch 9/60 781/781 [==============================] - 32s 41ms/step - loss: 1.0310 - accuracy: 0.6367 - val_loss: 1.0327 - val_accuracy: 0.6590 Epoch 10/60 781/781 [==============================] - 33s 43ms/step - loss: 1.0086 - accuracy: 0.6427 - val_loss: 0.9160 - val_accuracy: 0.6886 Epoch 11/60 781/781 [==============================] - 37s 47ms/step - loss: 0.9807 - accuracy: 0.6558 - val_loss: 0.9489 - val_accuracy: 0.6800 Epoch 12/60 781/781 [==============================] - 33s 42ms/step - loss: 0.9452 - accuracy: 0.6650 - val_loss: 0.9945 - val_accuracy: 0.6664 Epoch 13/60 781/781 [==============================] - 31s 40ms/step - loss: 0.9409 - accuracy: 0.6698 - val_loss: 0.8761 - val_accuracy: 0.7024 Epoch 14/60 781/781 [==============================] - 31s 40ms/step - loss: 0.9335 - accuracy: 0.6733 - val_loss: 0.9503 - val_accuracy: 0.6879 Epoch 15/60 781/781 [==============================] - 32s 41ms/step - loss: 0.9054 - accuracy: 0.6780 - val_loss: 0.8826 - val_accuracy: 0.7019 Epoch 16/60 781/781 [==============================] - 32s 41ms/step - loss: 0.9061 - accuracy: 0.6814 - val_loss: 0.8335 - val_accuracy: 0.7136 Epoch 17/60 781/781 [==============================] - 31s 40ms/step - loss: 0.8816 - accuracy: 0.6890 - val_loss: 0.8660 - val_accuracy: 0.7074 Epoch 18/60 781/781 [==============================] - 32s 41ms/step - loss: 0.8815 - accuracy: 0.6880 - val_loss: 0.9395 - val_accuracy: 0.6876 Epoch 19/60 781/781 [==============================] - 33s 42ms/step - loss: 0.8739 - accuracy: 0.6956 - val_loss: 1.0377 - val_accuracy: 0.6618 Epoch 20/60 781/781 [==============================] - 32s 41ms/step - loss: 0.8577 - accuracy: 0.6955 - val_loss: 0.8839 - val_accuracy: 0.7051 Epoch 21/60 781/781 [==============================] - 31s 40ms/step - loss: 0.8482 - accuracy: 0.7012 - val_loss: 0.8244 - val_accuracy: 0.7183 Epoch 22/60 781/781 [==============================] - 31s 40ms/step - loss: 0.8374 - accuracy: 0.7062 - val_loss: 0.8886 - val_accuracy: 0.7009 Epoch 23/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8393 - accuracy: 0.7059 - val_loss: 0.8817 - val_accuracy: 0.7047 Epoch 24/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8309 - accuracy: 0.7065 - val_loss: 0.9137 - val_accuracy: 0.6964 Epoch 25/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8298 - accuracy: 0.7070 - val_loss: 0.8749 - val_accuracy: 0.7096 Epoch 26/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8198 - accuracy: 0.7133 - val_loss: 0.8065 - val_accuracy: 0.7248 Epoch 27/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8087 - accuracy: 0.7121 - val_loss: 0.8044 - val_accuracy: 0.7244 Epoch 28/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8161 - accuracy: 0.7144 - val_loss: 0.9261 - val_accuracy: 0.6953 Epoch 29/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7979 - accuracy: 0.7156 - val_loss: 0.8093 - val_accuracy: 0.7251 Epoch 30/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7914 - accuracy: 0.7229 - val_loss: 0.8109 - val_accuracy: 0.7230 Epoch 31/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7930 - accuracy: 0.7196 - val_loss: 0.8614 - val_accuracy: 0.7109 Epoch 32/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7959 - accuracy: 0.7171 - val_loss: 0.8632 - val_accuracy: 0.7112 Epoch 33/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7791 - accuracy: 0.7257 - val_loss: 0.7808 - val_accuracy: 0.7352 Epoch 34/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7821 - accuracy: 0.7250 - val_loss: 0.7785 - val_accuracy: 0.7387 Epoch 35/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7797 - accuracy: 0.7256 - val_loss: 0.7833 - val_accuracy: 0.7354 Epoch 36/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7618 - accuracy: 0.7323 - val_loss: 0.7888 - val_accuracy: 0.7342 Epoch 37/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7602 - accuracy: 0.7325 - val_loss: 0.7305 - val_accuracy: 0.7433 Epoch 38/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7578 - accuracy: 0.7329 - val_loss: 0.7977 - val_accuracy: 0.7306 Epoch 39/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7555 - accuracy: 0.7316 - val_loss: 0.7836 - val_accuracy: 0.7346 Epoch 40/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7533 - accuracy: 0.7354 - val_loss: 0.7262 - val_accuracy: 0.7502 Epoch 41/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7430 - accuracy: 0.7374 - val_loss: 0.7791 - val_accuracy: 0.7362 Epoch 42/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7520 - accuracy: 0.7364 - val_loss: 0.7122 - val_accuracy: 0.7544 Epoch 43/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7399 - accuracy: 0.7396 - val_loss: 0.7575 - val_accuracy: 0.7413 Epoch 44/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7468 - accuracy: 0.7364 - val_loss: 0.8031 - val_accuracy: 0.7291 Epoch 45/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7434 - accuracy: 0.7387 - val_loss: 0.8123 - val_accuracy: 0.7285 Epoch 46/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7481 - accuracy: 0.7392 - val_loss: 0.7967 - val_accuracy: 0.7331 Epoch 47/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7373 - accuracy: 0.7383 - val_loss: 0.7225 - val_accuracy: 0.7545 Epoch 48/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7359 - accuracy: 0.7401 - val_loss: 0.7234 - val_accuracy: 0.7514 Epoch 49/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7350 - accuracy: 0.7383 - val_loss: 0.7998 - val_accuracy: 0.7298 Epoch 50/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7231 - accuracy: 0.7449 - val_loss: 0.7125 - val_accuracy: 0.7531 Epoch 51/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7278 - accuracy: 0.7412 - val_loss: 0.7913 - val_accuracy: 0.7360 Epoch 52/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7226 - accuracy: 0.7447 - val_loss: 0.8052 - val_accuracy: 0.7307 Epoch 53/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7384 - accuracy: 0.7405 - val_loss: 0.6825 - val_accuracy: 0.7657 Epoch 54/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7235 - accuracy: 0.7458 - val_loss: 0.7233 - val_accuracy: 0.7545 Epoch 55/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7202 - accuracy: 0.7499 - val_loss: 0.7300 - val_accuracy: 0.7514 Epoch 56/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7196 - accuracy: 0.7466 - val_loss: 0.7179 - val_accuracy: 0.7560 Epoch 57/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7220 - accuracy: 0.7457 - val_loss: 0.7563 - val_accuracy: 0.7459 Epoch 58/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7099 - accuracy: 0.7506 - val_loss: 0.7057 - val_accuracy: 0.7551 Epoch 59/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7109 - accuracy: 0.7497 - val_loss: 0.7156 - val_accuracy: 0.7569 Epoch 60/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7018 - accuracy: 0.7533 - val_loss: 0.7529 - val_accuracy: 0.7451
/Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:2325: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`Model.state_updates` will be removed in a future version. ' /Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1397: UserWarning: `layer.updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`layer.updates` will be removed in a future version. '
WARNING:tensorflow:FOR KERAS USERS: The object that you are saving contains one or more Keras models or layers. If you are loading the SavedModel with `tf.keras.models.load_model`, continue reading (otherwise, you may ignore the following instructions). Please change your code to save with `tf.keras.models.save_model` or `model.save`, and confirm that the file "keras.metadata" exists in the export directory. In the future, Keras will only load the SavedModels that have this file. In other words, `tf.saved_model.save` will no longer write SavedModels that can be recovered as Keras models (this will apply in TF 2.5). FOR DEVS: If you are overwriting _tracking_metadata in your class, this property has been used to save metadata in the SavedModel. The metadta field will be deprecated soon, so please move the metadata to a different file. INFO:tensorflow:Assets written to: /Users/suyashsrivastava/drig/models/ensemble_models/tiny_vgg_2.model/assets --------RUNNING PREDICTIONS------
/Users/suyashsrivastava/drig/utils.py:46: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. plt.show()
---------TRAINING 3 TINYVGG ON CIFAR10-------- --------BUILDING MODEL------------ --------COMPILING MODEL----------- --------TRAINING MODEL----------- Epoch 1/60 781/781 [==============================] - 27s 34ms/step - loss: 2.1684 - accuracy: 0.3174 - val_loss: 1.3746 - val_accuracy: 0.5053 Epoch 2/60 781/781 [==============================] - 27s 34ms/step - loss: 1.5561 - accuracy: 0.4611 - val_loss: 1.1929 - val_accuracy: 0.5745 Epoch 3/60 781/781 [==============================] - 27s 34ms/step - loss: 1.3930 - accuracy: 0.5144 - val_loss: 1.1648 - val_accuracy: 0.6015 Epoch 4/60 781/781 [==============================] - 27s 34ms/step - loss: 1.2854 - accuracy: 0.5505 - val_loss: 1.2694 - val_accuracy: 0.5902 Epoch 5/60 781/781 [==============================] - 27s 34ms/step - loss: 1.2088 - accuracy: 0.5753 - val_loss: 1.0904 - val_accuracy: 0.6300 Epoch 6/60 781/781 [==============================] - 27s 34ms/step - loss: 1.1567 - accuracy: 0.5929 - val_loss: 1.1518 - val_accuracy: 0.6262 Epoch 7/60 781/781 [==============================] - 27s 34ms/step - loss: 1.1103 - accuracy: 0.6103 - val_loss: 1.0806 - val_accuracy: 0.6380 Epoch 8/60 781/781 [==============================] - 27s 34ms/step - loss: 1.0745 - accuracy: 0.6200 - val_loss: 0.9197 - val_accuracy: 0.6881 Epoch 9/60 781/781 [==============================] - 27s 34ms/step - loss: 1.0231 - accuracy: 0.6414 - val_loss: 0.9849 - val_accuracy: 0.6632 Epoch 10/60 781/781 [==============================] - 27s 34ms/step - loss: 1.0079 - accuracy: 0.6469 - val_loss: 0.8728 - val_accuracy: 0.6988 Epoch 11/60 781/781 [==============================] - 27s 34ms/step - loss: 0.9860 - accuracy: 0.6516 - val_loss: 1.1663 - val_accuracy: 0.6221 Epoch 12/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9696 - accuracy: 0.6599 - val_loss: 1.1080 - val_accuracy: 0.6373 Epoch 13/60 781/781 [==============================] - 27s 34ms/step - loss: 0.9563 - accuracy: 0.6625 - val_loss: 1.0091 - val_accuracy: 0.6669 Epoch 14/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9454 - accuracy: 0.6691 - val_loss: 1.2080 - val_accuracy: 0.6158 Epoch 15/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9315 - accuracy: 0.6715 - val_loss: 1.0738 - val_accuracy: 0.6586 Epoch 16/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9232 - accuracy: 0.6743 - val_loss: 0.8387 - val_accuracy: 0.7117 Epoch 17/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8911 - accuracy: 0.6868 - val_loss: 0.7986 - val_accuracy: 0.7217 Epoch 18/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8816 - accuracy: 0.6894 - val_loss: 0.9573 - val_accuracy: 0.6748 Epoch 19/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8719 - accuracy: 0.6916 - val_loss: 0.7769 - val_accuracy: 0.7348 Epoch 20/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8744 - accuracy: 0.6905 - val_loss: 0.8512 - val_accuracy: 0.7112 Epoch 21/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8583 - accuracy: 0.7008 - val_loss: 0.8161 - val_accuracy: 0.7199 Epoch 22/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8540 - accuracy: 0.6993 - val_loss: 0.8136 - val_accuracy: 0.7189 Epoch 23/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8513 - accuracy: 0.6996 - val_loss: 0.8613 - val_accuracy: 0.7044 Epoch 24/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8447 - accuracy: 0.7024 - val_loss: 0.8812 - val_accuracy: 0.6967 Epoch 25/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8295 - accuracy: 0.7080 - val_loss: 0.8699 - val_accuracy: 0.7054 Epoch 26/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8160 - accuracy: 0.7118 - val_loss: 0.8714 - val_accuracy: 0.7082 Epoch 27/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8239 - accuracy: 0.7079 - val_loss: 0.7914 - val_accuracy: 0.7303 Epoch 28/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8088 - accuracy: 0.7122 - val_loss: 0.7786 - val_accuracy: 0.7346 Epoch 29/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8166 - accuracy: 0.7133 - val_loss: 0.7657 - val_accuracy: 0.7380 Epoch 30/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8100 - accuracy: 0.7112 - val_loss: 0.7999 - val_accuracy: 0.7271 Epoch 31/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8023 - accuracy: 0.7166 - val_loss: 0.9849 - val_accuracy: 0.6652 Epoch 32/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7879 - accuracy: 0.7200 - val_loss: 0.7490 - val_accuracy: 0.7405 Epoch 33/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7973 - accuracy: 0.7179 - val_loss: 0.9126 - val_accuracy: 0.6912 Epoch 34/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7913 - accuracy: 0.7208 - val_loss: 0.8551 - val_accuracy: 0.7079 Epoch 35/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7889 - accuracy: 0.7219 - val_loss: 0.7738 - val_accuracy: 0.7341 Epoch 36/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7774 - accuracy: 0.7271 - val_loss: 0.8431 - val_accuracy: 0.7146 Epoch 37/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7836 - accuracy: 0.7261 - val_loss: 0.7302 - val_accuracy: 0.7482 Epoch 38/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7771 - accuracy: 0.7257 - val_loss: 0.7707 - val_accuracy: 0.7383 Epoch 39/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7803 - accuracy: 0.7245 - val_loss: 0.7773 - val_accuracy: 0.7361 Epoch 40/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7674 - accuracy: 0.7313 - val_loss: 0.7125 - val_accuracy: 0.7550 Epoch 41/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7593 - accuracy: 0.7328 - val_loss: 0.8531 - val_accuracy: 0.7110 Epoch 42/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7551 - accuracy: 0.7378 - val_loss: 0.7491 - val_accuracy: 0.7437 Epoch 43/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7549 - accuracy: 0.7344 - val_loss: 0.7338 - val_accuracy: 0.7486 Epoch 44/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7532 - accuracy: 0.7351 - val_loss: 0.7817 - val_accuracy: 0.7347 Epoch 45/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7551 - accuracy: 0.7330 - val_loss: 0.7511 - val_accuracy: 0.7417 Epoch 46/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7558 - accuracy: 0.7315 - val_loss: 0.7456 - val_accuracy: 0.7451 Epoch 47/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7470 - accuracy: 0.7371 - val_loss: 0.7794 - val_accuracy: 0.7327 Epoch 48/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7462 - accuracy: 0.7386 - val_loss: 1.0168 - val_accuracy: 0.6735 Epoch 49/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7430 - accuracy: 0.7381 - val_loss: 0.8120 - val_accuracy: 0.7292 Epoch 50/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7426 - accuracy: 0.7396 - val_loss: 0.7242 - val_accuracy: 0.7535 Epoch 51/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7311 - accuracy: 0.7419 - val_loss: 0.7761 - val_accuracy: 0.7345 Epoch 52/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7275 - accuracy: 0.7449 - val_loss: 0.7763 - val_accuracy: 0.7323 Epoch 53/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7228 - accuracy: 0.7431 - val_loss: 0.7031 - val_accuracy: 0.7564 Epoch 54/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7305 - accuracy: 0.7410 - val_loss: 0.7390 - val_accuracy: 0.7486 Epoch 55/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7282 - accuracy: 0.7438 - val_loss: 0.7546 - val_accuracy: 0.7411 Epoch 56/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7297 - accuracy: 0.7460 - val_loss: 0.6933 - val_accuracy: 0.7604 Epoch 57/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7301 - accuracy: 0.7424 - val_loss: 0.7019 - val_accuracy: 0.7589 Epoch 58/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7191 - accuracy: 0.7478 - val_loss: 0.7010 - val_accuracy: 0.7585 Epoch 59/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7098 - accuracy: 0.7480 - val_loss: 0.7251 - val_accuracy: 0.7515 Epoch 60/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7127 - accuracy: 0.7462 - val_loss: 0.7958 - val_accuracy: 0.7341
/Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:2325: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`Model.state_updates` will be removed in a future version. ' /Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1397: UserWarning: `layer.updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`layer.updates` will be removed in a future version. '
WARNING:tensorflow:FOR KERAS USERS: The object that you are saving contains one or more Keras models or layers. If you are loading the SavedModel with `tf.keras.models.load_model`, continue reading (otherwise, you may ignore the following instructions). Please change your code to save with `tf.keras.models.save_model` or `model.save`, and confirm that the file "keras.metadata" exists in the export directory. In the future, Keras will only load the SavedModels that have this file. In other words, `tf.saved_model.save` will no longer write SavedModels that can be recovered as Keras models (this will apply in TF 2.5). FOR DEVS: If you are overwriting _tracking_metadata in your class, this property has been used to save metadata in the SavedModel. The metadta field will be deprecated soon, so please move the metadata to a different file. INFO:tensorflow:Assets written to: /Users/suyashsrivastava/drig/models/ensemble_models/tiny_vgg_3.model/assets --------RUNNING PREDICTIONS------
/Users/suyashsrivastava/drig/utils.py:46: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. plt.show()
---------TRAINING 4 TINYVGG ON CIFAR10-------- --------BUILDING MODEL------------ --------COMPILING MODEL----------- --------TRAINING MODEL----------- Epoch 1/60 781/781 [==============================] - 29s 37ms/step - loss: 2.1549 - accuracy: 0.3252 - val_loss: 1.5610 - val_accuracy: 0.4581 Epoch 2/60 781/781 [==============================] - 28s 36ms/step - loss: 1.5413 - accuracy: 0.4657 - val_loss: 1.2745 - val_accuracy: 0.5590 Epoch 3/60 781/781 [==============================] - 27s 35ms/step - loss: 1.3820 - accuracy: 0.5177 - val_loss: 1.3122 - val_accuracy: 0.5562 Epoch 4/60 781/781 [==============================] - 27s 35ms/step - loss: 1.2873 - accuracy: 0.5488 - val_loss: 1.2616 - val_accuracy: 0.5730 Epoch 5/60 781/781 [==============================] - 27s 35ms/step - loss: 1.2183 - accuracy: 0.5730 - val_loss: 1.3533 - val_accuracy: 0.5648 Epoch 6/60 781/781 [==============================] - 28s 35ms/step - loss: 1.1642 - accuracy: 0.5898 - val_loss: 1.1549 - val_accuracy: 0.6121 Epoch 7/60 781/781 [==============================] - 28s 35ms/step - loss: 1.1014 - accuracy: 0.6146 - val_loss: 1.0738 - val_accuracy: 0.6381 Epoch 8/60 781/781 [==============================] - 27s 35ms/step - loss: 1.0583 - accuracy: 0.6265 - val_loss: 1.1553 - val_accuracy: 0.6239 Epoch 9/60 781/781 [==============================] - 27s 35ms/step - loss: 1.0358 - accuracy: 0.6366 - val_loss: 1.0768 - val_accuracy: 0.6350 Epoch 10/60 781/781 [==============================] - 27s 35ms/step - loss: 1.0119 - accuracy: 0.6420 - val_loss: 0.9589 - val_accuracy: 0.6787 Epoch 11/60 781/781 [==============================] - 28s 36ms/step - loss: 0.9850 - accuracy: 0.6506 - val_loss: 1.1225 - val_accuracy: 0.6310 Epoch 12/60 781/781 [==============================] - 28s 36ms/step - loss: 0.9603 - accuracy: 0.6620 - val_loss: 0.9494 - val_accuracy: 0.6817 Epoch 13/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9465 - accuracy: 0.6689 - val_loss: 1.0116 - val_accuracy: 0.6663 Epoch 14/60 781/781 [==============================] - 27s 34ms/step - loss: 0.9302 - accuracy: 0.6726 - val_loss: 0.9369 - val_accuracy: 0.6782 Epoch 15/60 781/781 [==============================] - 28s 35ms/step - loss: 0.9151 - accuracy: 0.6784 - val_loss: 0.9115 - val_accuracy: 0.6970 Epoch 16/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8988 - accuracy: 0.6824 - val_loss: 1.0192 - val_accuracy: 0.6604 Epoch 17/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9109 - accuracy: 0.6795 - val_loss: 0.8933 - val_accuracy: 0.7001 Epoch 18/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8782 - accuracy: 0.6942 - val_loss: 0.8455 - val_accuracy: 0.7137 Epoch 19/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8677 - accuracy: 0.6936 - val_loss: 0.9465 - val_accuracy: 0.6851 Epoch 20/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8582 - accuracy: 0.6978 - val_loss: 0.8694 - val_accuracy: 0.7059 Epoch 21/60 781/781 [==============================] - 29s 38ms/step - loss: 0.8457 - accuracy: 0.7017 - val_loss: 0.8490 - val_accuracy: 0.7157 Epoch 22/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8552 - accuracy: 0.7013 - val_loss: 0.9074 - val_accuracy: 0.6960 Epoch 23/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8404 - accuracy: 0.7018 - val_loss: 0.9057 - val_accuracy: 0.6962 Epoch 24/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8430 - accuracy: 0.7027 - val_loss: 0.8064 - val_accuracy: 0.7266 Epoch 25/60 781/781 [==============================] - 29s 38ms/step - loss: 0.8309 - accuracy: 0.7081 - val_loss: 0.8481 - val_accuracy: 0.7172 Epoch 26/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8149 - accuracy: 0.7124 - val_loss: 1.0541 - val_accuracy: 0.6602 Epoch 27/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8088 - accuracy: 0.7166 - val_loss: 0.8135 - val_accuracy: 0.7229 Epoch 28/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8043 - accuracy: 0.7184 - val_loss: 0.7858 - val_accuracy: 0.7345 Epoch 29/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8036 - accuracy: 0.7178 - val_loss: 0.7841 - val_accuracy: 0.7333 Epoch 30/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7934 - accuracy: 0.7219 - val_loss: 0.9146 - val_accuracy: 0.7031 Epoch 31/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7933 - accuracy: 0.7199 - val_loss: 0.7369 - val_accuracy: 0.7497 Epoch 32/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7911 - accuracy: 0.7234 - val_loss: 0.8307 - val_accuracy: 0.7216 Epoch 33/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7801 - accuracy: 0.7252 - val_loss: 0.8232 - val_accuracy: 0.7249 Epoch 34/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7834 - accuracy: 0.7235 - val_loss: 0.7933 - val_accuracy: 0.7329 Epoch 35/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7732 - accuracy: 0.7311 - val_loss: 0.8286 - val_accuracy: 0.7216 Epoch 36/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7692 - accuracy: 0.7296 - val_loss: 0.8994 - val_accuracy: 0.6992 Epoch 37/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7762 - accuracy: 0.7285 - val_loss: 0.7866 - val_accuracy: 0.7337 Epoch 38/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7624 - accuracy: 0.7307 - val_loss: 0.7175 - val_accuracy: 0.7560 Epoch 39/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7601 - accuracy: 0.7315 - val_loss: 0.8349 - val_accuracy: 0.7209 Epoch 40/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7545 - accuracy: 0.7335 - val_loss: 0.7705 - val_accuracy: 0.7370 Epoch 41/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7542 - accuracy: 0.7354 - val_loss: 0.7491 - val_accuracy: 0.7465 Epoch 42/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7504 - accuracy: 0.7376 - val_loss: 0.7408 - val_accuracy: 0.7478 Epoch 43/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7579 - accuracy: 0.7335 - val_loss: 0.7785 - val_accuracy: 0.7375 Epoch 44/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7490 - accuracy: 0.7374 - val_loss: 0.7316 - val_accuracy: 0.7511 Epoch 45/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7397 - accuracy: 0.7386 - val_loss: 0.7657 - val_accuracy: 0.7410 Epoch 46/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7423 - accuracy: 0.7363 - val_loss: 0.7966 - val_accuracy: 0.7305 Epoch 47/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7394 - accuracy: 0.7417 - val_loss: 0.7406 - val_accuracy: 0.7495 Epoch 48/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7346 - accuracy: 0.7435 - val_loss: 0.7231 - val_accuracy: 0.7541 Epoch 49/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7276 - accuracy: 0.7448 - val_loss: 0.8307 - val_accuracy: 0.7233 Epoch 50/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7314 - accuracy: 0.7429 - val_loss: 0.7744 - val_accuracy: 0.7383 Epoch 51/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7205 - accuracy: 0.7480 - val_loss: 0.7077 - val_accuracy: 0.7591 Epoch 52/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7333 - accuracy: 0.7423 - val_loss: 0.7814 - val_accuracy: 0.7368 Epoch 53/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7194 - accuracy: 0.7443 - val_loss: 0.6948 - val_accuracy: 0.7625 Epoch 54/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7171 - accuracy: 0.7481 - val_loss: 0.7543 - val_accuracy: 0.7471 Epoch 55/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7273 - accuracy: 0.7436 - val_loss: 0.7769 - val_accuracy: 0.7414 Epoch 56/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7201 - accuracy: 0.7482 - val_loss: 0.7524 - val_accuracy: 0.7465 Epoch 57/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7070 - accuracy: 0.7486 - val_loss: 0.7248 - val_accuracy: 0.7583 Epoch 58/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7084 - accuracy: 0.7521 - val_loss: 0.7061 - val_accuracy: 0.7619 Epoch 59/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7113 - accuracy: 0.7502 - val_loss: 0.7489 - val_accuracy: 0.7496 Epoch 60/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7122 - accuracy: 0.7475 - val_loss: 0.7689 - val_accuracy: 0.7441
/Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:2325: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`Model.state_updates` will be removed in a future version. ' /Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1397: UserWarning: `layer.updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`layer.updates` will be removed in a future version. '
WARNING:tensorflow:FOR KERAS USERS: The object that you are saving contains one or more Keras models or layers. If you are loading the SavedModel with `tf.keras.models.load_model`, continue reading (otherwise, you may ignore the following instructions). Please change your code to save with `tf.keras.models.save_model` or `model.save`, and confirm that the file "keras.metadata" exists in the export directory. In the future, Keras will only load the SavedModels that have this file. In other words, `tf.saved_model.save` will no longer write SavedModels that can be recovered as Keras models (this will apply in TF 2.5). FOR DEVS: If you are overwriting _tracking_metadata in your class, this property has been used to save metadata in the SavedModel. The metadta field will be deprecated soon, so please move the metadata to a different file. INFO:tensorflow:Assets written to: /Users/suyashsrivastava/drig/models/ensemble_models/tiny_vgg_4.model/assets --------RUNNING PREDICTIONS------
/Users/suyashsrivastava/drig/utils.py:46: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. plt.show()
---------TRAINING 5 TINYVGG ON CIFAR10-------- --------BUILDING MODEL------------ --------COMPILING MODEL----------- --------TRAINING MODEL----------- Epoch 1/60 781/781 [==============================] - 28s 35ms/step - loss: 2.1280 - accuracy: 0.3328 - val_loss: 1.9007 - val_accuracy: 0.3948 Epoch 2/60 781/781 [==============================] - 28s 36ms/step - loss: 1.5486 - accuracy: 0.4647 - val_loss: 1.3451 - val_accuracy: 0.5219 Epoch 3/60 781/781 [==============================] - 28s 36ms/step - loss: 1.3791 - accuracy: 0.5186 - val_loss: 1.2486 - val_accuracy: 0.5606 Epoch 4/60 781/781 [==============================] - 28s 36ms/step - loss: 1.2639 - accuracy: 0.5549 - val_loss: 1.4947 - val_accuracy: 0.5133 Epoch 5/60 781/781 [==============================] - 29s 38ms/step - loss: 1.1986 - accuracy: 0.5788 - val_loss: 1.3743 - val_accuracy: 0.5702 Epoch 6/60 781/781 [==============================] - 30s 38ms/step - loss: 1.1378 - accuracy: 0.6002 - val_loss: 1.2135 - val_accuracy: 0.6000 Epoch 7/60 781/781 [==============================] - 29s 37ms/step - loss: 1.0717 - accuracy: 0.6235 - val_loss: 1.0164 - val_accuracy: 0.6564 Epoch 8/60 781/781 [==============================] - 27s 35ms/step - loss: 1.0664 - accuracy: 0.6256 - val_loss: 1.1812 - val_accuracy: 0.6258 Epoch 9/60 781/781 [==============================] - 27s 35ms/step - loss: 1.0347 - accuracy: 0.6351 - val_loss: 1.0176 - val_accuracy: 0.6607 Epoch 10/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9913 - accuracy: 0.6527 - val_loss: 0.9646 - val_accuracy: 0.6763 Epoch 11/60 781/781 [==============================] - 27s 35ms/step - loss: 0.9816 - accuracy: 0.6572 - val_loss: 0.9700 - val_accuracy: 0.6818 Epoch 12/60 781/781 [==============================] - 28s 36ms/step - loss: 0.9573 - accuracy: 0.6628 - val_loss: 0.8894 - val_accuracy: 0.6999 Epoch 13/60 781/781 [==============================] - 28s 36ms/step - loss: 0.9424 - accuracy: 0.6706 - val_loss: 0.9393 - val_accuracy: 0.6852 Epoch 14/60 781/781 [==============================] - 29s 37ms/step - loss: 0.9284 - accuracy: 0.6723 - val_loss: 0.9243 - val_accuracy: 0.6825 Epoch 15/60 781/781 [==============================] - 29s 37ms/step - loss: 0.9232 - accuracy: 0.6753 - val_loss: 0.9516 - val_accuracy: 0.6882 Epoch 16/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8968 - accuracy: 0.6829 - val_loss: 0.8483 - val_accuracy: 0.7154 Epoch 17/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8843 - accuracy: 0.6899 - val_loss: 0.9006 - val_accuracy: 0.7013 Epoch 18/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8817 - accuracy: 0.6854 - val_loss: 0.8949 - val_accuracy: 0.7021 Epoch 19/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8715 - accuracy: 0.6943 - val_loss: 0.8488 - val_accuracy: 0.7102 Epoch 20/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8655 - accuracy: 0.6977 - val_loss: 0.9150 - val_accuracy: 0.6943 Epoch 21/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8404 - accuracy: 0.7061 - val_loss: 0.8302 - val_accuracy: 0.7206 Epoch 22/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8459 - accuracy: 0.7021 - val_loss: 0.8007 - val_accuracy: 0.7227 Epoch 23/60 781/781 [==============================] - 28s 35ms/step - loss: 0.8457 - accuracy: 0.7008 - val_loss: 0.8490 - val_accuracy: 0.7167 Epoch 24/60 781/781 [==============================] - 27s 34ms/step - loss: 0.8282 - accuracy: 0.7087 - val_loss: 0.8354 - val_accuracy: 0.7139 Epoch 25/60 781/781 [==============================] - 29s 37ms/step - loss: 0.8183 - accuracy: 0.7130 - val_loss: 0.7872 - val_accuracy: 0.7300 Epoch 26/60 781/781 [==============================] - 28s 36ms/step - loss: 0.8184 - accuracy: 0.7125 - val_loss: 0.8340 - val_accuracy: 0.7192 Epoch 27/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8068 - accuracy: 0.7136 - val_loss: 0.7950 - val_accuracy: 0.7275 Epoch 28/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8100 - accuracy: 0.7165 - val_loss: 0.7572 - val_accuracy: 0.7386 Epoch 29/60 781/781 [==============================] - 27s 35ms/step - loss: 0.8118 - accuracy: 0.7148 - val_loss: 0.8039 - val_accuracy: 0.7315 Epoch 30/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7950 - accuracy: 0.7198 - val_loss: 0.7667 - val_accuracy: 0.7388 Epoch 31/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7922 - accuracy: 0.7236 - val_loss: 0.8434 - val_accuracy: 0.7186 Epoch 32/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7865 - accuracy: 0.7226 - val_loss: 0.7734 - val_accuracy: 0.7353 Epoch 33/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7723 - accuracy: 0.7282 - val_loss: 0.8438 - val_accuracy: 0.7130 Epoch 34/60 781/781 [==============================] - 30s 38ms/step - loss: 0.7798 - accuracy: 0.7219 - val_loss: 0.8317 - val_accuracy: 0.7222 Epoch 35/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7720 - accuracy: 0.7299 - val_loss: 0.8114 - val_accuracy: 0.7289 Epoch 36/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7702 - accuracy: 0.7269 - val_loss: 0.8260 - val_accuracy: 0.7224 Epoch 37/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7631 - accuracy: 0.7290 - val_loss: 0.8232 - val_accuracy: 0.7212 Epoch 38/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7646 - accuracy: 0.7257 - val_loss: 0.7628 - val_accuracy: 0.7373 Epoch 39/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7571 - accuracy: 0.7327 - val_loss: 0.7826 - val_accuracy: 0.7348 Epoch 40/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7586 - accuracy: 0.7317 - val_loss: 0.7813 - val_accuracy: 0.7341 Epoch 41/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7561 - accuracy: 0.7334 - val_loss: 0.7773 - val_accuracy: 0.7353 Epoch 42/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7395 - accuracy: 0.7394 - val_loss: 0.7775 - val_accuracy: 0.7339 Epoch 43/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7606 - accuracy: 0.7330 - val_loss: 0.8161 - val_accuracy: 0.7219 Epoch 44/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7546 - accuracy: 0.7337 - val_loss: 0.8063 - val_accuracy: 0.7260 Epoch 45/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7450 - accuracy: 0.7392 - val_loss: 0.8206 - val_accuracy: 0.7256 Epoch 46/60 781/781 [==============================] - 29s 38ms/step - loss: 0.7263 - accuracy: 0.7425 - val_loss: 0.7627 - val_accuracy: 0.7411 Epoch 47/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7392 - accuracy: 0.7410 - val_loss: 0.7539 - val_accuracy: 0.7408 Epoch 48/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7362 - accuracy: 0.7403 - val_loss: 0.7524 - val_accuracy: 0.7414 Epoch 49/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7448 - accuracy: 0.7366 - val_loss: 0.7589 - val_accuracy: 0.7429 Epoch 50/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7273 - accuracy: 0.7440 - val_loss: 0.7230 - val_accuracy: 0.7488 Epoch 51/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7327 - accuracy: 0.7417 - val_loss: 0.7760 - val_accuracy: 0.7374 Epoch 52/60 781/781 [==============================] - 27s 34ms/step - loss: 0.7258 - accuracy: 0.7488 - val_loss: 0.7400 - val_accuracy: 0.7448 Epoch 53/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7232 - accuracy: 0.7433 - val_loss: 0.7477 - val_accuracy: 0.7421 Epoch 54/60 781/781 [==============================] - 28s 36ms/step - loss: 0.7275 - accuracy: 0.7462 - val_loss: 0.7591 - val_accuracy: 0.7415 Epoch 55/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7286 - accuracy: 0.7429 - val_loss: 0.7644 - val_accuracy: 0.7399 Epoch 56/60 781/781 [==============================] - 28s 35ms/step - loss: 0.7211 - accuracy: 0.7481 - val_loss: 0.7281 - val_accuracy: 0.7508 Epoch 57/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7173 - accuracy: 0.7487 - val_loss: 0.7386 - val_accuracy: 0.7477 Epoch 58/60 781/781 [==============================] - 29s 37ms/step - loss: 0.7199 - accuracy: 0.7453 - val_loss: 0.7197 - val_accuracy: 0.7527 Epoch 59/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7142 - accuracy: 0.7488 - val_loss: 0.7386 - val_accuracy: 0.7459 Epoch 60/60 781/781 [==============================] - 27s 35ms/step - loss: 0.7081 - accuracy: 0.7484 - val_loss: 0.7591 - val_accuracy: 0.7411
/Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:2325: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`Model.state_updates` will be removed in a future version. ' /Users/suyashsrivastava/miniforge3/envs/dl4cv/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1397: UserWarning: `layer.updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically. warnings.warn('`layer.updates` will be removed in a future version. '
WARNING:tensorflow:FOR KERAS USERS: The object that you are saving contains one or more Keras models or layers. If you are loading the SavedModel with `tf.keras.models.load_model`, continue reading (otherwise, you may ignore the following instructions). Please change your code to save with `tf.keras.models.save_model` or `model.save`, and confirm that the file "keras.metadata" exists in the export directory. In the future, Keras will only load the SavedModels that have this file. In other words, `tf.saved_model.save` will no longer write SavedModels that can be recovered as Keras models (this will apply in TF 2.5). FOR DEVS: If you are overwriting _tracking_metadata in your class, this property has been used to save metadata in the SavedModel. The metadta field will be deprecated soon, so please move the metadata to a different file. INFO:tensorflow:Assets written to: /Users/suyashsrivastava/drig/models/ensemble_models/tiny_vgg_5.model/assets --------RUNNING PREDICTIONS------
/Users/suyashsrivastava/drig/utils.py:46: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. plt.show()
visualize_network(model)
report_files=list(glob.glob(os.path.abspath(os.path.join(os.path.pardir, "models/ensemble_models","*.txt"))))
for file_path in report_files:
report_file=open(file_path)
print(report_file.readlines()[15])
weighted avg 0.77 0.74 0.74 10000 weighted avg 0.78 0.75 0.74 10000 weighted avg 0.77 0.73 0.73 10000 weighted avg 0.77 0.74 0.74 10000 weighted avg 0.77 0.74 0.74 10000
model_training_graphs=list(glob.glob(os.path.abspath(os.path.join(os.path.pardir, "models/ensemble_models","*.png"))))
display_image(cv2.imread(model_training_graphs[0]))
display_image(cv2.imread(model_training_graphs[1]))
display_image(cv2.imread(model_training_graphs[2]))
display_image(cv2.imread(model_training_graphs[3]))
display_image(cv2.imread(model_training_graphs[4]))
import glob
from keras.models import load_model
model_paths=list(glob.glob(os.path.abspath(os.path.join(os.path.pardir, "models/ensemble_models","*.model"))))
models=[load_model(model_path) for model_path in model_paths]
predictions=list()
for model in models:
prediction=model.predict(test_x, batch_size=64)
predictions.append(prediction)
(10000, 10) (10000, 10) (10000, 10) (10000, 10) (10000, 10)
predictions=np.average(predictions, axis=0)
print(classification_report(test_y.argmax(axis=1), predictions.argmax(axis=1), target_names=classes))
precision recall f1-score support airplane 0.85 0.78 0.82 1000 automobile 0.93 0.89 0.91 1000 bird 0.85 0.55 0.67 1000 cat 0.69 0.41 0.52 1000 deer 0.69 0.74 0.71 1000 dog 0.84 0.51 0.63 1000 frog 0.48 0.98 0.64 1000 horse 0.87 0.82 0.84 1000 ship 0.88 0.91 0.89 1000 truck 0.81 0.93 0.87 1000 accuracy 0.75 10000 macro avg 0.79 0.75 0.75 10000 weighted avg 0.79 0.75 0.75 10000