I was trying to train a model for kaggle’s spaceship titanic dataset. Spaceship Titanic | Kaggle. But while training the model the losses I am getting are nan values. Can anyone please let me know what mistake I am making.

The following code is after I have preprocessed the dataframe and converted it to tensor.

norm_l = tf.keras.layers.Normalization(axis=-1)

norm_l.adapt(x_train) # learns mean, variance

Xn = norm_l(x_train)

model=Sequential([

tf.keras.Input(shape=(15,)),

Dense(units=128,activation=‘relu’),

Dense(units=64,activation=‘relu’),

Dense(units=32,activation=‘relu’),

Dense(units=16,activation=‘relu’),

Dense(units=4,activation=‘relu’),

Dense(units=2,activation=‘relu’),

Dense(units=1,activation=‘sigmoid’)

])

model.compile(

loss=tf.keras.losses.BinaryCrossentropy(),

optimizer=tf.keras.optimizers.Adam(learning_rate=0.001),

)

history = model.fit(

Xn,y_train,

epochs=40

)

And this is the output I am getting.

Epoch 1/40

182/182 [==============================] - 1s 1ms/step - loss: nan: 0s - loss: n

Epoch 2/40

182/182 [==============================] - 0s 1ms/step - loss: nan

Epoch 3/40

182/182 [==============================] - 0s 1ms/step - loss: nan

Epoch 4/40

182/182 [==============================] - 0s 1ms/step - loss: nan

Epoch 5/40

182/182 [==============================] - 0s 1ms/step - loss: nan

Epoch 6/40

182/182 [==============================] - 0s 1ms/step - loss: nan

Epoch 7/40

182/182 [==============================] - 0s 1ms/step - loss: nan