scipy.ndimage.zoom即使在小型阵列上也要花费很长时间

时间:2018-10-22 02:42:15

标签: python scipy keras zoom

我正在尝试在MNIST上应用VGG16。只需测试10个数据集。但是变焦需要很长时间

将numpy导入为np     导入密码     从keras.applications.vgg16导入VGG16     从scipy导入ndimage     进口喀拉拉邦     从keras.datasets导入mnist     从keras.models导入顺序     从keras.layers导入Dense,Dropout     从keras.optimizers导入Adam     从keras.layers导入Flatten     导入matplotlib.pyplot作为plt     从keras.layers导入Dense,GlobalAveragePooling2D     从keras.models导入模型

(x_train, y_train),(x_test, y_test) = keras.datasets.mnist.load_data()

x_train = np.reshape(x_train, (-1,28,28,1)).astype('float32')/255
x_test = np.reshape(x_test, (-1,28,28,1)).astype('float32')/255
y_train = keras.utils.to_categorical(y_train)
y_test = keras.utils.to_categorical(y_test)

data_slice = 10
x_train = x_train[:data_slice,:]
y_train = y_train[:data_slice,:]
x_test = x_test[:data_slice,:]
y_test = y_test[:data_slice,:]

print('after slice')
x_train = scipy.ndimage.zoom(x_train,(8))
print('after x_train zoom')
x_test = scipy.ndimage.zoom(x_test,(8))
print('after x_test zoom')
y_train = scipy.ndimage.zoom(y_train,(8))
print('after y_train zoom')
y_test = scipy.ndimage.zoom(y_test,(8))
print('after y_test zoom')

print('after zoom')
base_model=VGG16(include_top='false', weights='imagenet')
x = base_model.output`enter code here`
print(x.shape)
x = Flatten(name='flatten')(x)
x = GlobalAveragePooling2D()(x)

0 个答案:

没有答案