Tensorflow Convolucional Neural Networks

Asked

Viewed 67 times

2

Hey, you guys, hey! I have a problem, I believe, in my training set. I have a numpy array with 649 images for training my network however when starting the training(model.fit) I see that only 21 images are "coming" for this training. Someone would know to tell me what might be going on?

model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, padding="same", activation="relu", input_shape=[100, 100, 3]))
model.add(tf.keras.layers.Conv2D(filters=32, kernel_size=3, padding="same", activation="relu"))
model.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=2, padding='valid'))
model.add(tf.keras.layers.Conv2D(filters=64, kernel_size=3, padding="same", activation="relu"))
model.add(tf.keras.layers.Conv2D(filters=64, kernel_size=3, padding="same", activation="relu"))
model.add(tf.keras.layers.MaxPool2D(pool_size=2, strides=2, padding='valid'))
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(units=128, activation='relu'))
model.add(tf.keras.layers.Dropout(0.2))
model.add(tf.keras.layers.Dense(units=128, activation='relu'))
model.add(tf.keras.layers.Dropout(0.2))
model.summary()
model.compile(loss="sparse_categorical_crossentropy",
              optimizer="Adam", metrics=["sparse_categorical_accuracy"])
model.fit(X_train, y_train, epochs=25)

1 answer

2


The function .fit() has as a standard a batch_size=32. This means that for a weight upgrade (backpropagation), 32 images will be used at a time. As your dataset has 649 images, will be realziados 21 backpropagations per time. (649/32 = 20.3)

If you want 649 backpropagations per season, use batch_size=1.

  • Thank you so much, Alex! this is my first project in the area of AI. I’m going through some haha suffocations!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.