我在具有 4 个 GPU 的 EC2 实例上训练 TensorFlow 代码并收到此错误。我的训练和测试策略就像下面的代码。有什么想法或建议吗?
提前致谢!
mirrored_strategy = tf.distribute.MirroredStrategy()
test_ds = test_ds.repeat(repeat_size).shuffle(1000).batch(global_batch_size).prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
dist_dataset_test = mirrored_strategy.experimental_distribute_dataset(test_ds)
TypeError: Failed to convert object of type <class 'tensorflow.python.distribute.values.PerReplica'> to Tensor. Contents: PerReplica:{
0: Tensor("cond_4/Identity:0",shape=(None,12,64),dtype=float32,device=/job:localhost/replica:0/task:0/device:GPU:0),1: Tensor("cond_5/Identity:0",device=/job:localhost/replica:0/task:0/device:GPU:1),2: Tensor("cond_6/Identity:0",device=/job:localhost/replica:0/task:0/device:GPU:2),3: Tensor("cond_7/Identity:0",device=/job:localhost/replica:0/task:0/device:GPU:3)
}. Consider casting elements to a supported type.