提问者:小点点

模块sscy. ndimage没有属性插值TensorflowCNN


这是我的代码的一部分,在数据增强之前,model.fit是工作的,但是在数据增强之后,我得到了这个错误;

属性错误:模块“sscy. ndimage”没有属性“插值”

这是所有导入库的列表;

import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPool2D, Flatten, Dense
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import scipy.ndimage
import numpy
import random
import pathlib
import os
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import zipfile
import wget
# Create an augmented data generator
train_datagen_augmented = ImageDataGenerator(rescale=1/255.,
                                             rotation_range=0.2,
                                             width_shift_range=0.2,
                                             height_shift_range=0.2,
                                             zoom_range=0.2,
                                             horizontal_flip=True)

train_data_augmented = train_datagen_augmented.flow_from_directory(train_dir,
                                                                  target_size=(224, 224),
                                                                  batch_size=32,
                                                                  class_mode='categorical')


# Clone the model (use the same architecture)
model_3 = tf.keras.models.clone_model(model)

# Compile the cloned model (same setup as used for model)
model_3.compile(loss="categorical_crossentropy",
              optimizer=tf.keras.optimizers.Adam(),
              metrics=["accuracy"])

# Fit the model
history_3 = model_3.fit(train_data_augmented, # use augmented data
                          epochs=5,
                          steps_per_epoch=len(train_data_augmented),
                          validation_data=test_data,
                          validation_steps=len(test_data))

Traceback(最近一次调用最后一次):

File"",第6行,history_3=model_3.fit(train_data_augmented,#使用增强数据

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\tensorflow\python\keras\engine\training.py",第1133行,适合data_handler=data_adapterget_data_handler(

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\tensorflow\python\keras\engine\data_adapter.py",第1364行,get_data_handler返回DataHandler(*args,**kwargs)

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\tensorflow\python\keras\engine\data_adapter.py",第1154行,在init self中。_adapter=adapter_cls(

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\张量流\python\keras\engine\data_adapter.py",第932行,在初始化超级(KerasSequenceAdapter, self).init(

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\tensorflow\python\keras\engine\data_adapter.py",第809行,在init peek中,x=self._peek_and_restore(x)

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\tensorflow\python\keras\engine\data_adapter.py",第943行,_peek_and_restore返回x[0], x

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\keras_preprocessing\image\iterator.py",第65行,在getitemback self中。_get_batches_of_transformed_samples(index_array)

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\keras_preprocessing\image\iterator.py",第238行,_get_batches_of_transformed_samplesx=self.image_data_generator.apply_transform(x, params)

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\keras_preprocessing\image\image_data_generator.py",第863行,apply_transformx=apply_affine_transform(x,transform_parameters. get('theta',0),

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\keras_preprocessing\image\affine_transformations.py",第327行,apply_affine_transformchannel_images=[ndimage. interpolation.affine_transform(

文件"C:\用户\batuh\AppData\漫游\Python\Python38\site-包\keras_preprocessing\image\affine_transformations.py",第327行,channel_images=[ndimage. interpolation.affine_transform(

属性错误:模块“sscy. ndimage”没有属性“插值”


共1个答案

匿名用户

我发现了问题。问题是我的anaconda虚拟环境中缺少s的。我以为我看到的时候安装了s的

属性错误:模块“sscy. ndimage”没有属性“插值”

谢谢你的提示@simpleApp。很抱歉用心不在焉的错误打扰你…解决方案是安装s的