Hi everybody,
When I am running the code pasted below, the model is just training for “multiplier” =1 or =4.
Running the same code in google colab → just training for multiplier=1
Is there any mistake in how I am using DenseNet here?
Thanks in advance, appreciate your help!
import numpy as np
import tensorflow as tf
from tensorflow.keras.applications.densenet import DenseNet201
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.losses import BinaryCrossentropy
random_array = np.random.rand(128,128,3)
image = tf.convert_to_tensor(
random_array
)
label = tf.constant(0)
model = DenseNet201(
include_top=False, weights='imagenet', input_tensor=None,
input_shape=(128, 128, 3), pooling=None, classes=2
)
model.compile(
optimizer=Adam(),
loss=BinaryCrossentropy(),
metrics=['accuracy'],
)
for multiplier in range(1,20):
print(f"Using multiplier {multiplier}")
x_train = np.array([image]*multiplier)
y_train = np.array([label]*multiplier)
try:
model.fit(x=x_train,y=y_train, epochs=2)
except:
print("Not training...")
pass