I am trying to find out the number of FLOPS my model uses using this code that I got online:
def get_flops(model):
run_meta = tf.RunMetadata()
opts = tf.profiler.ProfileOptionBuilder.float_operation()
# We use the Keras session graph in the call to the profiler.
flops = tf.profiler.profile(graph=K.get_session().graph,
run_meta=run_meta, cmd='op', options=opts)
return flops.total_float_ops # Prints the "flops" of the model.
# .... Define your model here ....
print(get_flops(model))
However, running this code gives me this error:
Traceback (most recent call last):
File "/Users/Desktop/FYP/Code/Python/code/main.py", line 243, in <module>
print(get_flops(model))
File "/Users/Desktop/FYP/Code/Python/code/main.py", line 232, in get_flops
run_meta = tf.RunMetadata()
AttributeError: module 'tensorflow' has no attribute 'RunMetadata'
How can I bypass this error? I have read online and the only help that I got is to update my tensorflow version. However, this is the most updated version.