TensorFlow报错:input_data.py only integer scalar arrays can be converted to a scalar

TensorFlow 教程第一个例子下载数据报错了。国外找到的解决方法:

you can modify the function:

def _read32(bytestream):
    dt = numpy.dtype(numpy.uint32).newbyteorder('>')
    return numpy.frombuffer(bytestream.read(4), dtype=dt)

new version:

def _read32(bytestream):
    dt = numpy.dtype(numpy.uint32).newbyteorder('>')
    return numpy.frombuffer(bytestream.read(4), dtype=dt)[0]

add [0] in the end.

This appears to be an issue with the latest version of Numpy. A recent change made it an error to treat a single-element array as a scalar for the purposes of indexing.


原文地址:

http://stackoverflow.com/questions/42128830/typeerror-only-integer-scalar-arrays-can-be-converted-to-a-scalar-index

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个误信息"only integer scalar arrays can be converted to a scalar index"通常出现在使用np.concatenate函数时,当输入的参数中包含非整数标量数组时会出现这个误。具体来说,当我们尝试将一个非整数标量数组用作索引时,这个误就会出现。这意味着参数中的某个数组不是整数类型或者不是标量类型。为了解决这个问题,我们需要确保传递给np.concatenate函数的所有数组都是整数类型的标量数组。将所有参数都转换为整数类型的标量数组后,再重新运行代码,就可以解决这个误了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [解决问题:only integer scalar arrays can be converted to a scalar index](https://blog.csdn.net/yuan187393/article/details/128963957)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [成功解决TypeError: only integer scalar arrays can be converted to a scalar index](https://blog.csdn.net/weixin_46713695/article/details/127335679)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值