python - Python返回'UFuncTypeError:ufunc'add'不包含循环..'
问题描述
我正在研究图像深度学习。运行此代码时出现此错误:
from PIL import Image
using_image_num = 10000
batch_num = 2
for category in classes:
for j in range(using_image_num):
img = category[j,:j+784].reshape(1,28,28,1)
batch = 0
flow = datagen.flow(img, batch_size = 1, save_to_dir = saved_location, save_prefix = 'augmented_' + classes[i], save_format='png')
for augmenting_batch in flow:
batch += 1
if batch > batch_num:
break
print("augmented " + category + " is saved.")
错误看起来像:
UFuncTypeError Traceback (most recent call last)
<ipython-input-42-e9dd2f490a52> in <module>
15 img = category[j,:j+784].reshape(1,28,28,1)
16 batch = 0
---> 17 flow = datagen.flow(img, batch_size = 1, save_to_dir = saved_location, save_prefix = 'augmented_' + classes[i], save_format='png')
18 for augmenting_batch in flow:
19 batch += 1
UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U10'), dtype('<U10')) -> dtype('<U10')
当我在 colab 中运行此代码时,它会很好地返回结果。
我不知道为什么这不适用于 Jupyter 笔记本。我在 AWS ec2 服务器上操作了这段代码。一开始,我以为 colab 和 jupyter 的工作方式类似,但结果并非如此。我发现 U10 表示 unicode .... 但我陷入了这个问题而没有任何解决方案..
解决方案
推荐阅读
- python - Python:当我停止程序时不要删除数据。只加载一次非常大的数据库
- python - SQLite JSON查询以计算嵌套列表中的项目数
- python - 无法提供图表作为 youtube 搜索 API 的参数
- c# - Selenium C# Click() 在使用 Jenkins 时无法访问另一个 URL
- r - 在不同的列中分隔一串以空格分隔的数据框
- python - OSX 上的加密升级问题
- c - 查找具有最大/最小位数集的数字
- vue.js - 从 vuex 获取时,Vue 路由器 id 未定义
- pdf - 支持在 Xamarin Forms 中将 HTML 转换为 PDF
- python - 基于两列中的模糊匹配合并两个数据帧