I need to add mixed precision to my code in order to save some memory. Specifically, I have tried adding mixed precision policy near line 27 in https://github.com/nimRobotics/google-research/blob/master/ravens/train.py, below is the code excerpt
import argparse
import datetime
import os
import numpy as np
from ravens import agents
from ravens import Dataset
import tensorflow as tf
# tf.keras.mixed_precision.set_global_policy('mixed_float16')
# OR
# policy = tf.keras.mixed_precision.Policy('mixed_float16')
# mixed_precision.set_global_policy(policy)
Both the methods result in attribute error as shown below, I'm using Google Colab with TF 2.3.0
Using tf.keras.mixed_precision.set_global_policy('mixed_float16') results in
Traceback (most recent call last):
File "train.py", line 28, in <module>
tf.keras.mixed_precision.set_global_policy('mixed_float16')
AttributeError: module 'tensorflow.keras.mixed_precision' has no attribute 'set_global_policy'
Using
policy = tf.keras.mixed_precision.Policy('mixed_float16')
mixed_precision.set_global_policy(policy)
results in
Traceback (most recent call last):
File "train.py", line 29, in <module>
policy = tf.keras.mixed_precision.Policy('mixed_float16')
AttributeError: module 'tensorflow.keras.mixed_precision' has no attribute 'Policy'
Any help or hints will be highly appreciated!