Home > other >  Question about fitting a model in Tensorflow
Question about fitting a model in Tensorflow

Time:04-23

Newbie here. I recently started learning about deep learning and tried to implement a model in which I would fit for a multiclassification. I’m working with text data. I wanted to know what could be the issue of why my accuracy and val scores are stay the same, and mg loss is consistently 0.enter image description here

CodePudding user response:

Your results actually make sense, but you seem a bit confused, so to to make things more clear:

  • loss is the result of the cost function you chose (here categorical_crossentropy) based on your training data.
  • accuracy is a metric. Your model isn't trying to improve accuracy, it just returns your this value during training and is based on your training data. The aim of the optimization function is to minimize loss, not to increase accuracy.
  • val_loss is the value of your cost function for your cross-validation data, so it's not to be compared with accuracy.

So since your model completed the first epoch with zero loss, it makes some sense to keep returning zero loss results on the next epochs (and the other values staying the same).

Personally, I find it weird you started with zero loss on the first epoch for both datasets (independent of accuracy) . My advice is to read more on this to understand how each of them is calculated (see answers here and here) and at what step of the fitting they're calculated (here)

Also for feature reference keep in mind to not post code in image, see tour.

CodePudding user response:

You are using only one neuron in our output layer but you said you are doing a multiclass classification. You can use one neuron with sigmoid activation when you have binary class classification. But when you have more than two classes, the number of neurons in the output layer should be equal to the number of classes in your dataset and you should use the softmax function. The softmax gives you the probability of the input falling in a particular class.

  • Related