Since I need to train a model with multiple labels, I need to use loss function tf.nn.sigmoid_cross_entropy_with_logits. This function has two parameters: logits and loss.
Is parameter logitsis the value of predicted y? How can I pass this value before I compile model? I cannot predict y before I compile and fit model, right?
This is my code:
import tensorflow as tf
from tensorflow import keras
model = keras.Sequential([keras.layers.Dense(50, activation='tanh', input_shape=[100]),
keras.layers.Dense(30, activation='relu'),
keras.layers.Dense(50, activation='tanh'),
keras.layers.Dense(100, activation='relu'),
keras.layers.Dense(8)])
model.compile(optimizer='rmsprop',
loss=tf.nn.sigmoid_cross_entropy_with_logits(logits=y_pred), labels=y), # <---How to figure out y_pred here?
metrics=['accuracy'])
model.fit(x, y, epochs=10, batch_size=32)
y_pred = model.predict(x) # <--- Now I got y_pred after compile, fit and predict
I'm using tensorflow v2.1.0