简体   繁体   中英

Getting accuracy: 0.0000e+00 in my Tensor flow model

I was trying to practice my skills in CNN and deep learning by solving a Challenge on Kaggle. It's a Regression-based. This is the model - MODEL

the dataset is - https://www.kaggle.com/piantic/osic-pulmonary-fibrosis-progression-basic-eda

model = model_architechture()
    
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.01), loss='mae',metrics= 'accuracy') 

tr_p, vl_p = train_test_split(P, shuffle=True, train_size= 0.8)



er = tf.keras.callbacks.EarlyStopping(
    monitor="val_loss",
    min_delta=1e-3,
    patience=5,
    verbose=0,
    mode="auto",
    baseline=None,
    restore_best_weights=True,
)

model.fit_generator(IGenerator(keys=tr_p, 
                               a = A, 
                               tab = TAB), 
                    steps_per_epoch = 50,
                    validation_data=IGenerator(keys=vl_p, 
                               a = A, 
                               tab = TAB),
                    validation_steps = 10, 
                    callbacks = [er], 
                    epochs=5)

This is the output i am getting. As you can see, the accuracy is 0. Is there a way i can calculate the accuracy of this model.

Epoch 1/5
50/50 [==============================] - 23s 467ms/step - loss: 17.4784 - accuracy: 0.0000e+00 - val_loss: 6.6384 - val_accuracy: 0.0000e+00
Epoch 2/5
50/50 [==============================] - 23s 458ms/step - loss: 5.4008 - accuracy: 0.0000e+00 - val_loss: 3.8762 - val_accuracy: 0.0000e+00
Epoch 3/5
50/50 [==============================] - 23s 453ms/step - loss: 4.7755 - accuracy: 0.0000e+00 - val_loss: 4.3907 - val_accuracy: 0.0000e+00
Epoch 4/5
50/50 [==============================] - 23s 456ms/step - loss: 4.8971 - accuracy: 0.0000e+00 - val_loss: 4.0197 - val_accuracy: 0.0000e+00
Epoch 5/5
50/50 [==============================] - 23s 461ms/step - loss: 4.7031 - accuracy: 0.0000e+00 - val_loss: 3.9652 - val_accuracy: 0.0000e+00

Accuracy metric is used to measure the classification accuracy. It can not be used to measure regression. Not always predictions are equal to expected values, even it differ from small value it leads to zero accuracy.

Use regression metric such as mean absolute error , mean squared error , r2 score .

List of Regression metrics can found here , choose which is appropriate for your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM