TransWikia.com

" loss: nan - accuracy: 0.0000e+00 - mae: nan " for all epochs while training my Neural network

Data Science Asked by Aryan Sethi on August 6, 2020

Background:
I made a simple game using python library ‘Turtle’ in which there is a long plank with a ball balanced on top of it. I can press right or left arrow keys to rotate the plank (either clockwise or anticlockwise) which makes the ball roll to the either side.

Issue:
I wanted to train a neural network to make this whole process automated(to balance the ball on plank). So I myself played the game and recorded the states(conditions) and my corresponding actions(buttons pressed) for a period of 2 minutes in the form of a csv. At the end, I got a dataset of 1300 conditions( eg. velocity of ball, direction of velocity, inclination of plank, etc) and the corresponding 1300 actions i took to balance the ball on the plank. Now when I try to train my neural network on this data, I get 0 accuracy and ‘nan’ mae for all the epochs.
Where am i going wrong,
PLEASE HELP !

I’ve attached the code below

#all necessary imports

df=pd.read_csv('train.txt')

model= Sequential([
               Dense(units=16,activation='relu',input_shape=(5,)),
               Dense(units=32,activation='relu'),
               Dense(units=10,activation='relu'),
               Dense(units=1,activation='softmax')
            ])

model.compile(optimizer=Adam(learning_rate=0.0001),loss='sparse_categorical_crossentropy',metrics=['accuracy','mae'])

X_train=df[['x','y','theta','u','v']]
Y_train=df['action']

X_train= X_train.astype('float32')/10
Y_train= Y_train.astype('float32')/10

model.fit(X_train,Y_train,batch_size=40,epochs=20)

And this is what I’m getting for all the epochs :

loss: nan - accuracy: 0.0000e+00 - mae: nan

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP