IOError: Unable to open file (File signature not found)

 
  

keras加载模型有两种方式

1.model = load_model('model.h5') 2. model = Sequential() model.add(Conv2D(32, (3, 3), padding='same', input_shape=(3, IMG_SIZE, IMG_SIZE), activation='relu')) model.add(Conv2D(32, (3, 3), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) # model.add(Dropout(1)) model.add(Conv2D(64, (3, 3), padding='same', activation='relu')) model.add(Conv2D(64, (3, 3), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) # model.add(Dropout(1)) model.add(Conv2D(128, (3, 3), padding='same', activation='relu')) model.add(Conv2D(128, (3, 3), activation='relu')) model.add(MaxPooling2D(pool_size=(2, 2))) # model.add(Dropout(1)) model.add(Flatten()) model.add(Dense(512, activation='relu')) # model.add(Dropout(1)) model.add(Dense(NUM_CLASSES, activation='softmax')) model.load_weights('model.h5') adam = Adam(lr=1e-6) model.compile(loss='mse', optimizer=adam)

又一次加载时报错了,IOError: Unable to open file (File signature not found)

h5py\_objects.pyx in h5py._objects.with_phil.wrapper (C:\aroot\work\h5py\_objects.c:2579)()

h5py\_objects.pyx in h5py._objects.with_phil.wrapper (C:\aroot\work\h5py\_objects.c:2538)()

h5py\h5f.pyx in h5py.h5f.open (C:\aroot\work\h5py\h5f.c:1813)()

OSError: Unable to open file (File signature not found)

原因:model.h5内容丢失了,大小为59k

重新训练一个正常的model.h5就可以了


你可能感兴趣的:(keras)