我正在尝试训练一个机器学习模型来自动分割心脏。我使用的是TensorFlow 2.8.0。下面是我的一段代码:
for step in range(steps):
print('\n****** Epoch {} Step {} ******'.format(epoch, step))
batch_img0, batch_img1, batch_mask0, batch_mask1 = next(train_generator)
print(model.train_on_batch([batch_img0, batch_img1, batch_mask0], batch_mask1, sample_weight=None, class_weight=None))
在这个for循环的层次上,我收到以下错误:
File "C:\Users\talba\Downloads\base de données\CardiacMotionFlow-master\segmentation\finetune_lvrv_net.py", line 323, in finetune_lvrv_net
print(model.train_on_batch([batch_img0, batch_img1, batch_mask0],
File "C:\Users\talba\Downloads\jupiter\lib\site-packages\keras\engine\training.py", line 2093, in train_on_batch
logs = self.train_function(iterator)
File "C:\Users\talba\Downloads\jupiter\lib\site-packages\tensorflow\python\util\traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\talba\Downloads\jupiter\lib\site-packages\tensorflow\python\framework\func_graph.py", line 1147, in autograph_handler
raise e.ag_error_metadata.to_exception(e)
AttributeError: in user code:
File "C:\Users\talba\Downloads\jupiter\lib\site-packages\keras\engine\training.py", line 1021, in train_function *
return step_function(self, iterator)
File "C:\Users\talba\Downloads\base de données\CardiacMotionFlow-master\segmentation\..\helpers.py", line 1356, in dice_coef5_0 *
y_pred = tf.to_float(y_pred)
AttributeError: module 'tensorflow' has no attribute 'to_float'
误差显然在这条线的水平上
print(model.train_on_batch([batch_img0, batch_img1, batch_mask0], batch_mask1, sample_weight=None, class_weight=None))
我收到属性错误AttributeError: module 'tensorflow' has no attribute 'to_float'
,但我没有在代码中写一行float。我不明白。有人能帮我解决这个问题吗?
1条答案
按热度按时间dxxyhpgq1#
使用tf.totf.cast(x,tf.float32)代替www.example.com _float(x)