うまくモデルの重みを読み込むことができません。
このようなエラーを調べてみたのですが、見つかりませんでした。
方法があったら教えていただきたいです。
Python
1 model = Sequential() 2 model.add(Dense(100, activation='Mish')) 3 model.add(Dense(100, activation='Mish')) 4 model.add(Dense(MAX_ANSWER+1,activation="softmax")) 5 6 model.compile(loss='categorical_crossentropy',optimizer='adamax',metrics=['accuracy']) 7 if flag: 8 pass 9 else: 10 model.load_weights('transfer0.h5') 11 model.fit(x_train, y_train, epochs=1, batch_size=1, validation_data=(x_test, y_test)) 12 model.save_weights('transfer0.h5') 13 predict_prob=model.predict(x_test) 14 predict_classes=np.argmax(predict_prob,axis=1) 15 true_classes = y_test1 16 print(confusion_matrix(true_classes, predict_classes))
<ipython-input-41-3d2d5d6f3f30> in learner(x_train, y_train, x_test, y_test, y_test1, flag) 213 pass 214 else: --> 215 model.load_weights('transfer0.h5') 216 model.fit(x_train, y_train, epochs=1, batch_size=1, validation_data=(x_test, y_test)) 217 model.save_weights('transfer0.h5') /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in load_weights(self, filepath, by_name, skip_mismatch, options) 2198 if not self._is_graph_network and not self.built: 2199 raise ValueError( -> 2200 'Unable to load weights saved in HDF5 format into a subclassed ' 2201 'Model which has not created its variables yet. Call the Model ' 2202 'first, then load the weights.') ValueError: Unable to load weights saved in HDF5 format into a subclassed Model which has not created its variables yet. Call the Model first, then load the weights.
あなたの回答
tips
プレビュー