Python tensorflow ValueError:仅使用逻辑调用'sparse\u softmax\u cross\u entropy\u`

Python tensorflow ValueError:仅使用逻辑调用'sparse\u softmax\u cross\u entropy\u`,python,tensorflow,machine-learning,logistic-regression,mnist,Python,Tensorflow,Machine Learning,Logistic Regression,Mnist,是基于旧版本的TensorFlow编写的。 我正在试着运行它。然而,由于Tensorflow版本,它给出了错误。我得到以下错误 据我所知,我不可能安装旧版本的Opencv 我该如何解决这个问题 /home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning: Passing (type, 1) or '1typ

是基于旧版本的TensorFlow编写的。 我正在试着运行它。然而,由于Tensorflow版本,它给出了错误。我得到以下错误

据我所知,我不可能安装旧版本的Opencv

我该如何解决这个问题

/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:458: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:459: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:460: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:461: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:462: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:465: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "/home/user/Videos/Chapter-three/2 - MNIST Logistic Regression L2 Regularization.py", line 63, in <module>
    labels, loss_op = loss(logits)
  File "/home/user/Videos/Chapter-three/2 - MNIST Logistic Regression L2 Regularization.py", line 38, in loss
    logits, tf.argmax(batch_labels, dimension=1), name='xentropy')
  File "/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 1661, in sparse_softmax_cross_entropy_with_logits
    labels, logits)
  File "/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 1510, in _ensure_xent_args
    "named arguments (labels=..., logits=..., ...)" % name)
ValueError: Only call `sparse_softmax_cross_entropy_with_logits` with named arguments (labels=..., logits=..., ...)

Process finished with exit code 1
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:458:FutureWarning:Passing(type,1)或'1type'作为type的同义词不推荐使用;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_qint8=np.dtype([(“qint8”,np.int8,1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:459:FutureWarning:Passing(type,1)或“1type”作为type的同义词不推荐使用;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_quint8=np.dtype([(“quint8”,np.uint8,1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:460:FutureWarning:Passing(type,1)或'1type'作为type的同义词不推荐使用;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_qint16=np.dtype([(“qint16”,np.int16,1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:461:FutureWarning:Passing(type,1)或'1type'作为type的同义词不推荐使用;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_quint16=np.dtype([(“quint16”,np.uint16,1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:462:FutureWarning:Passing(type,1)或'1type'作为type的同义词不推荐使用;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_qint32=np.dtype([(“qint32”,np.int32,1)])
/home/user/PycharmProjects/untitled/venv/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:465:FutureWarning:Passing(type,1)或'1type'作为type的同义词不推荐使用;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
np_resource=np.dtype([(“resource”,np.ubyte,1)])
提取MNIST_数据/train-images-idx3-ubyte.gz
提取MNIST_数据/train-labels-idx1-ubyte.gz
提取MNIST_数据/t10k-images-idx3-ubyte.gz
提取MNIST_数据/t10k-labels-idx1-ubyte.gz
回溯(最近一次呼叫最后一次):
文件“/home/user/Videos/Chapter three/2-MNIST Logistic回归L2 regulation.py”,第63行,在
标签,损失\u op=损失(logits)
文件“/home/user/Videos/Chapter three/2-MNIST Logistic回归L2 regulation.py”,第38行,丢失
logits,tf.argmax(批次标签,维度=1),name='xentropy')
文件“/home/user/PycharmProjects/untitled/venv/lib/python3.6/site packages/tensorflow/python/ops/nn_ops.py”,第1661行,以稀疏形式显示,带有登录名
标签、登录)
文件“/home/user/PycharmProjects/untitled/venv/lib/python3.6/site packages/tensorflow/python/ops/nn_ops.py”,第1510行,在参数中
命名参数(标签=…,逻辑项=…,…)%name)
ValueError:仅调用带有命名参数(labels=…,logits=…,…)的'sparse\u softmax\u cross\u entropy\u with_logits')
进程已完成,退出代码为1

交叉熵=tf.nn.sparse\u-softmax\u-cross\u-entropy\u替换为logits(logits,tf.argmax(批次标签,维度=1),name='xentropy')
替换为
交叉熵=tf.nn.sparse\u-softmax\u-cross\u-entropy\u-logits(logits=logits,标签=tf.argmax(批次标签,维度=1),name='xentropy')

这是因为该方法希望传递的参数命名