诸葛亮孔明卧龙 2022-02-28 21:08 采纳率: 100%
浏览 49
已结题

tensorflow张量dtype=float_ref

我是一个在用Tensorflow做机器学习毕设的本科生,ValueError: Tensor conversion requested dtype float32_ref for Tensor with dtype float32:'Tensor("Adam/dense/kernel/m/Initializer/zeros:0", shape=(256, 513), dtype=float32)这个问题最后是怎么解决的,大佬救一下。

我的错误

Traceback (most recent call last):
File "C:/python/machinelearning/venv/Include/RCFusion/code/train_and_eval.py", line 376, in
train_step_conv1x1 = tf.keras.optimizers.RMSprop(learning_rate=decayed_lr*lr_mult_conv1x1).get_updates(loss=loss, params=trainable_variables_conv1x1)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\keras\optimizer_v2\optimizer_v2.py", line 504, in get_updates
return [self.apply_gradients(grads_and_vars)]
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\keras\optimizer_v2\optimizer_v2.py", line 433, in apply_gradients
self._create_slots(var_list)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\keras\optimizer_v2\rmsprop.py", line 123, in _create_slots
self.add_slot(var, "rms")
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\keras\optimizer_v2\optimizer_v2.py", line 585, in add_slot
initial_value=initial_value)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 260, in call
return cls._variable_v2_call(*args, **kwargs)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 254, in _variable_v2_call
shape=shape)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 235, in
previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\ops\variable_scope.py", line 2552, in default_variable_creator_v2
shape=shape)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\ops\variables.py", line 262, in call
return super(VariableMetaclass, cls).call(*args, **kwargs)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py", line 1406, in init
distribute_strategy=distribute_strategy)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py", line 1538, in _init_from_args
name="initial_value", dtype=dtype)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1184, in convert_to_tensor
return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1242, in convert_to_tensor_v2
as_ref=False)
File "C:\python\machinelearning\venv\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1273, in internal_convert_to_tensor
(dtype.name, value.dtype.name, value))
ValueError: Tensor conversion requested dtype float32_ref for Tensor with dtype float32: <tf.Tensor 'RMSprop/conv1x1/redux_rgb_res1_depth/kernel/rms/Initializer/zeros:0' shape=(1, 1, 64, 256) dtype=float32>

Process finished with exit code 1

  • 写回答

1条回答 默认 最新

  • 爱晚乏客游 2022-03-01 00:12
    关注


    img


    你看下像他这里这么该能不能行,不行的话建议你的版本和源码要求的版本对上一般就不会出现这个问题了。或者你可以找找你用的其他人实现,不同的tf版本或者pytorch版本

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 3月9日
  • 已采纳回答 3月1日
  • 创建了问题 2月28日

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化