Python TFlearn存储和加载模块,无需网络初始化

Python TFlearn存储和加载模块,无需网络初始化,python,tflearn,rnn,Python,Tflearn,Rnn,您好,我已经创建了一个模型,并使用TFlearn对其进行了培训 # Network building net = input_data(shape=[None, max_document_length]) net = embedding(net, input_dim=Vocabulary_size, output_dim=128) net = simple_rnn(net, 512) net = dropout(net, 0.5) net = fully_connected(net, n_cla

您好,我已经创建了一个模型,并使用TFlearn对其进行了培训

# Network building
net = input_data(shape=[None, max_document_length])
net = embedding(net, input_dim=Vocabulary_size, output_dim=128)
net = simple_rnn(net, 512)
net = dropout(net, 0.5)
net = fully_connected(net, n_class, activation='softmax')
net = regression(net, optimizer='adam', loss='categorical_crossentropy')

# Training
model = tflearn.DNN(net, clip_gradients=0.)
model.fit(doc_vec, label, validation_set=0.1, show_metric=True, batch_size=100)

#saving the files
model.save('path')
但是,当我试图在一个新文件中恢复这个模型时,我被要求再次给出整个网络构建,并加载模型并进行预测

net = input_data(shape=[None, max_document_length])
net = embedding(net, input_dim=Vocabulary_size, output_dim=128)
net = simple_rnn(net, 512)
net = dropout(net, 0.5)
net = fully_connected(net, n_class, activation='softmax')
net = regression(net, optimizer='adam', loss='categorical_crossentropy')
model = tflearn.DNN(net, clip_gradients=0.)
model.load('path')
print(model.predict_label(input))
我试图pickle保存网络和模型,但它抛出了一个错误。 那么,我该怎么做才能确保我不提供整个网络,只保存模型并恢复它,然后使用model.predict,就像使用sklearn一样