Dinesh
Dinesh

Reputation: 744

Unsupported Operand type - Divide seconds to minutes

This is the code I have:

start = time()
model.fit(X, y, validation_split=0.3, epochs=2, batch_size=16, verbose=1, callbacks=[es, mc])
print('Training time in seconds: %.2f' % (time()-start)/60)

I need to divide my seconds to minutes (using /60). However, there is an operand error.

Error:

---> 20 print('Training time in seconds: %.2f' % (time()-start)/60) TypeError: unsupported operand type(s) for /: 'str' and 'int'

How could I fix this ?

Upvotes: 0

Views: 30

Answers (1)

Wondercricket
Wondercricket

Reputation: 7882

You need another pair of parenthesis around your time calculation. Currently, it's formatting the string with just time() - start and then trying to divide on the formatted string

print('Training time in seconds: %.2f' % ((time() - start) / 60))

Upvotes: 3

Related Questions