I use the latest tensorflow version and get this error
this is the code
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.datasets import mnist
x = tf.random.normal(shape=(3, 299, 299, 3))
y = tf.constant([0, 1, 2])
model = keras.applications.InceptionV3(include_top=True)
print(model.summary())
# for input you can also do model.input,
# then for base_outputs you can obviously
# choose other than simply removing the last one :)
base_inputs = model.layers[0].input
base_outputs = model.layers[-2].output
classifier = layers.Dense(3)(base_outputs)
new_model = keras.Model(inputs=base_inputs, outputs=classifier)
new_model.compile(
optimizer=keras.optimizers.Adam(),
loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=["accuracy"],
)
print(new_model.summary())
new_model.fit(x, y, epochs=15, verbose=2)
I tried everything and still cant find the answer, on a youtube tutorial this works but here doesnt
New contributor
Andrei Arseni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.