Computer Vision News - January 2023

8 Computer Vision Tools _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= conv2d (Conv2D) (None, 128, 128, 32) 2432 _________________________________________________________________ max_pooling2d (MaxPooling2D) (None, 64, 64, 32) 0 _________________________________________________________________ conv2d_1 (Conv2D) (None, 64, 64, 64) 18496 _________________________________________________________________ max_pooling2d_1 (MaxPooling2 (None, 32, 32, 64) 0 _________________________________________________________________ conv2d_2 (Conv2D) (None, 32, 32, 128) 73856 _________________________________________________________________ max_pooling2d_2 (MaxPooling2 (None, 16, 16, 128) 0 _________________________________________________________________ flatten (Flatten) (None, 32768) 0 _________________________________________________________________ dense (Dense) (None, 6) 196614 _________________________________________________________________ dense_1 (Dense) (None, 1) 7 ================================================================= Total params: 291,405 Trainable params: 291,405 Non-trainable params: 0 _________________________________________________________________ Notice in this definition is how the number of filters doubled block-by-block: 64, 128, 256. This is a common pattern. Since the MaxPool2D layer is reducing the size of the feature maps, we can afford to increase the quantity we create. Step 3 - Train We can train this model just like the model from Lesson 1: compile it with an optimizer along with a loss and metric appropriate for binary classification. model.compile( optimizer=tf.keras.optimizers.Adam(epsilon=0.01), loss='binary_crossentropy', metrics=['binary_accuracy'] ) history = model.fit( ds_train, validation_data=ds_valid, epochs=40, ) Epoch 1/40 80/80 [==============================] - 19s 239ms/step - loss: 0.6830 - binary_accuracy: 0.5697 - val_loss: 0.6714 - val_binary_accuracy: 0.5771 [. . .] Epoch 40/40 80/80 [==============================] - 3s 40ms/step - loss: 0.0905 - binary_accuracy: 0.9650 - val_loss: 0.5981 - val_binary_accuracy: 0.8131 import pandas as pd

RkJQdWJsaXNoZXIy NTc3NzU=