问题描述
train_generator = train_datagen.flow_from_directory(
'/home/idu/Desktop/COV19D/train/',color_mode = "grayscale",target_size=(512,512),# All images are 512 * 512
batch_size=batch_size,classes = ['covid','non-covid'],class_mode='binary')
转出的模型代码如下:
SIZE = 512
VGG_model = VGG16(include_top=False,weights=None,input_shape=(SIZE,SIZE,1))
for layer in VGG_model.layers:
layer.trainable = False
feature_extractor=VGG_model.predict(train_generator)
最后一条命令抛出错误:
Traceback (most recent call last):
File "<ipython-input-28-b9bad68819ec>",line 1,in <module>
feature_extractor=VGG_model.predict(train_generator)
File "/home/idu/.local/lib/python3.6/site-packages/keras/engine/training.py",line 1681,in predict
steps_per_execution=self._steps_per_execution)
File "/home/idu/.local/lib/python3.6/site-packages/keras/engine/data_adapter.py",line 1348,in get_data_handler
return DataHandler(*args,**kwargs)
File "/home/idu/.local/lib/python3.6/site-packages/keras/engine/data_adapter.py",line 1150,in __init__
model=model)
File "/home/idu/.local/lib/python3.6/site-packages/keras/engine/data_adapter.py",line 793,in __init__
peek,x = self._peek_and_restore(x)
File "/home/idu/.local/lib/python3.6/site-packages/keras/engine/data_adapter.py",line 850,in _peek_and_restore
peek = next(x)
File "/home/idu/.local/lib/python3.6/site-packages/keras_preprocessing/image/iterator.py",line 104,in __next__
return self.next(*args,**kwargs)
File "/home/idu/.local/lib/python3.6/site-packages/keras_preprocessing/image/iterator.py",line 116,in next
return self._get_batches_of_transformed_samples(index_array)
File "/home/idu/.local/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 "/home/idu/.local/lib/python3.6/site-packages/keras_preprocessing/image/utils.py",line 309,in img_to_array
x = np.asarray(img,dtype=dtype)
File "/home/idu/.local/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
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)