'float' object has no attribute 'round'

Viewed 21397

I have a code was shown below:

history['test_acc'].append(results.history['val_dense_5_accuracy'][0]) 

then I want to print like below:

 print('Epoch: '+str(epoch)+'/'+str(epochs-1), 'Learning rate:', 
      'Test_acc:', history['test_acc'][-1].round(4),
      'Test_loss:', history['test_loss'][-1].round(4))`

but in this this line:

'Test_acc:', history['test_acc'][-1].round(4)

i have this error: 'float' object has no attribute 'round' what's the problem?

1 Answers

The problem is that round is a built-in top level function, not a method on floats. Change:

history['test_acc'][-1].round(4)

to:

round(history['test_acc'][-1], 4) 

with a similar change to the test_loss expression.

Related