其他分享
首页 > 其他分享> > TypeError: cast() missing 1 required positional argument: ‘dtype‘的解决方案

TypeError: cast() missing 1 required positional argument: ‘dtype‘的解决方案

作者:互联网

1 问题描述

Traceback (most recent call last):
  File "e:\matlab\CNN-classification\LSTM\train_test.py", line 75, in <module>
    accuracy = tf.reduce_mean(tf.cast(correctPred), tf.float32)
  File "D:\Program\Anaconda3\envs\cat\lib\site-packages\tensorflow\python\util\dispatch.py", line 180, in wrapper     
    return target(*args, **kwargs)
TypeError: cast() missing 1 required positional argument: 'dtype'

File "e:\matlab\CNN-classification\LSTM\train_test.py", line 75:

accuracy = tf.reduce_mean(tf.cast(correctPred), tf.float32)

2 解决方案

就是参数错误,

正确的应该是

accuracy = tf.reduce_mean(tf.cast(correctPred, tf.float32))

标签:TypeError,missing,dtype,py,reduce,cast,tf,correctPred,float32
来源: https://blog.csdn.net/a1456123a/article/details/115498884