cifar10: TypeError: range() takes at least 2 arguments (1 given)
cifar10: TypeError: range() takes at least 2 arguments (1 given)
当我构建文件时:cifar10_train.py
,出现:
...
File ".../cifar10.py", line 271, in loss
indices = tf.reshape(tf.range(FLAGS.batch_size), [FLAGS.batch_size, 1])
TypeError: range() takes at least 2 arguments (1 given)
文件 cifar10.py
出现问题。
我修改命令如下:
#indices = tf.reshape(tf.range(FLAGS.batch_size), [FLAGS.batch_size, 1])
indices = tf.reshape(range(FLAGS.batch_size), [FLAGS.batch_size, 1])
那么,代码运行良好。
您似乎使用的是 TensorFlow 版本 0.5 和更新版本的 cifar10_train.py
脚本。 tf.range()
的签名在 0.5 版本发布后更改为接受单个参数(如 Python range()
内置函数)。
我总是推荐 upgrading to the latest version TensorFlow,因为运行时自初始版本以来在性能和稳定性方面有了很多改进。
如果这不起作用,则采用以下等效代码from the original release:
indices = tf.reshape(tf.range(0, FLAGS.batch_size, 1), [FLAGS.batch_size, 1])
当我构建文件时:cifar10_train.py
,出现:
...
File ".../cifar10.py", line 271, in loss
indices = tf.reshape(tf.range(FLAGS.batch_size), [FLAGS.batch_size, 1])
TypeError: range() takes at least 2 arguments (1 given)
文件 cifar10.py
出现问题。
我修改命令如下:
#indices = tf.reshape(tf.range(FLAGS.batch_size), [FLAGS.batch_size, 1])
indices = tf.reshape(range(FLAGS.batch_size), [FLAGS.batch_size, 1])
那么,代码运行良好。
您似乎使用的是 TensorFlow 版本 0.5 和更新版本的 cifar10_train.py
脚本。 tf.range()
的签名在 0.5 版本发布后更改为接受单个参数(如 Python range()
内置函数)。
我总是推荐 upgrading to the latest version TensorFlow,因为运行时自初始版本以来在性能和稳定性方面有了很多改进。
如果这不起作用,则采用以下等效代码from the original release:
indices = tf.reshape(tf.range(0, FLAGS.batch_size, 1), [FLAGS.batch_size, 1])