ValueError: This model has not yet been built. Build the model first by calling build() or calling

ValueError: This model has not yet been built. Build the model first by calling build() or calling

当我们训练好模型保存下来之后,想要读取模型以及相关参数,可能会出现以下问题ValueError: This model has not yet been built. Build the model first by calling build() or calling。

解决办法一:目前CSDN上的很多方法添加model.bulid((None,时间步/或W,特征/或H))
估计对大部分有用。

我的解决办法:修改原训练模型的出入层InputLayer

'''原始代码'''
model = Sequential()
model.add(InputLayer(input_shape=(X.shape[1],X.shape[2])))
model.add(Conv1D(filters=128,kernel_size=3,
			padding="valid",activation="relu",
			kernel_regularizer='l2'))

修改之后

model = Sequential()
model.add(Conv1D(filters=128,kernel_size=3,padding="valid",
		activation="relu",kernel_regularizer='l2',
		input_shape=(X.shape[1],X.shape[2])))

下次再训练完,加载模型就不会出现这项的问题了。

你可能感兴趣的:(笔记,python,tensorflow,神经网络,深度学习)