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

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日

悬赏问题

  • ¥20 数据结构—复杂度分析
  • ¥15 如何使用单链表编写学生信息管理系统?
  • ¥15 完成课题以及ppt 在21号之前完成
  • ¥15 懂的来,你应该知道我在说什么,我需要你的帮助
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 maccms影视模板 制作影视网站失败 求
  • ¥15 stm32按键设置闹钟数进退位不正常
  • ¥15 自己写的测试驱动程序无法启动
  • ¥15 三电平逆变器中点电位平衡问题
  • ¥20 这怎么写啊 java课设