python-3.x - Azure ML 中的 Keras model.fit 失败
问题描述
我正在尝试用很少的图像在 Azure ML 中训练一个简单的测试模型。我正在将培训代码从本地 PC 推送到 Azure 云。它使用图像生成器数据流在云中找到图像(下面的屏幕截图)。
模型创建也很好,我可以打印模型的摘要。但是当我在做 model.fit 时,得到了这个预期的错误。但是当我在本地 PC 上运行相同的代码时,我没有收到任何错误。
任何线索都会有所帮助。提前致谢。
model.fit(train_generator,validation_data=valid_generator,epochs=1,steps_per_epoch=STEP_SIZE_TRAIN,validation_steps=STEP_SIZE_VALID)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 108, in _method_wrapper
return method(self, *args, **kwargs)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1063, in fit
steps_per_execution=self._steps_per_execution)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py", line 1117, in __init__
model=model)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py", line 916, in __init__
**kwargs)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py", line 786, in __init__
peek, x = self._peek_and_restore(x)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/tensorflow/python/keras/engine/data_adapter.py", line 920, in _peek_and_restore
return x[0], x
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/keras_preprocessing/image/iterator.py", line 65, in __getitem__
return self._get_batches_of_transformed_samples(index_array)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/keras_preprocessing/image/iterator.py", line 231, in _get_batches_of_transformed_samples
x = img_to_array(img, data_format=self.data_format)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/keras_preprocessing/image/utils.py", line 309, in img_to_array
x = np.asarray(img, dtype=dtype)
File "/azureml-envs/azureml_ad50fdad40ee16a2c46e9c45c93908c0/lib/python3.6/site-packages/numpy/core/_asarray.py", line 83, in asarray
return array(a, dtype, copy=False, order=order)
TypeError: __array__() takes 1 positional argument but 2 were given
更新:通过降级 PIL 解决了这个问题,从 Kaveh 在这篇文章中的回答中找到了解决方案:here。我不会删除这个问题,因为有人可能正在寻找类似的问题。
问候,
解决方案
推荐阅读
- vb.net - 如何在 VB.NET 中检测按下的键
- php - 需要laravel中动态时间的空闲时间段
- java - logback:在滚动之前签署日志文件
- geolocation - 雪花查询以获取多边形内的数据
- mysql - 在mysql中仅插入时间戳中的日期
- jquery - 悬停时更改班级背景
- javascript - 设置显示编码页面请求
- tensorflow - 张量流中有logit函数吗?
- javascript - 在元素的开头生成innerHTML
- java - 错误 [org.apache.catalina.core.ContainerBase.[jboss.web].exception: java.lang.ClassNotFoundException: org.apache.commons.collections.ArrayStack