Python 此时不支持会话“”中的某些键:%s';,口述键([';度量衡';]))
我试图使一个基本的图像分类项目,可以区分任何两个或多个类别。 我已经写了下面的代码,并在标题中指出了一个错误。 如何解决此错误? 下面是我的代码Python 此时不支持会话“”中的某些键:%s';,口述键([';度量衡';])),python,machine-learning,image-processing,deep-learning,computer-vision,Python,Machine Learning,Image Processing,Deep Learning,Computer Vision,我试图使一个基本的图像分类项目,可以区分任何两个或多个类别。 我已经写了下面的代码,并在标题中指出了一个错误。 如何解决此错误? 下面是我的代码 from keras.preprocessing import image from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential from keras.layers import Conv2D,MaxPooling2D f
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D,MaxPooling2D
from keras.layers import Activation,Dropout,Flatten,Dense
from keras import backend as k
import numpy as np
img_width,img_height = 64,64
train_data_dir = 'dataset/training_set'
validation_data_dir = 'dataset/test_set'
nb_train_samples = 1000
nb_validation_samples = 100
epochs = 50
batch_size = 20
if k.image_data_format() == 'channel-first':
input_shape = (3,img_width,img_height)
else:
input_shape = (img_width,img_height,3)
train_datagen = ImageDataGenerator(rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True)
test_datagen = ImageDataGenerator(rescale = 1./255)
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size=(img_width,img_height),
batch_size = batch_size,
class_mode = 'binary')
validation_generator=test_datagen.flow_from_directory(
validation_data_dir,
target_size = (img_width,img_height),
batch_size = batch_size,
class_mode = 'binary')
model = Sequential()
model.add(Conv2D(32,(3,3),input_shape = input_shape))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size = (2,2)))
model.summary()
model.add(Conv2D(32,(3,3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size = (2,2)))
#model.add(Conv2D(64,(3,3)))
#model.add(Activation('relu'))
#model.add(MaxPooling2D(pool_size = (2,2)))
model.summary()
model.add(Flatten())
model.add(Dense(units = 128, activation = "relu"))
model.add(Dense(units = 1, activation = "sigmoid"))
model.add(Dropout(0.5))
optimizer = keras.optimizers.sgd(lr = 0.1)
model.compile(loss='binary_crossentropy',
optimizer = optimizer,
metrices = ['accuracy'])
model.fit_generator(train_generator,
steps_per_epoch = nb_train_samples // batch_size,
epochs = epochs,
validation_data = validation_generator,
validation_steps = nb_validation_samples // batch_size)
除了最后一段代码外,每一行都工作正常。
在运行最后一段代码时,
我得到以下错误
(“会话中的某些键\u当前不受支持:%s”,dict\u键(['metrices'))您应该查找
度量值而不是度量值吗