我试图从加载在一个线程中的tensorflow模型(全局mModel)中检索输出(使用keras.models.model_from_json和load_weights),并在one服务器上在另一个线程中运行(使用预测)。如何提供来自隐藏层和网络权重的输出?
在一些通过创建模型来预测中间层模型的尝试中,我得到了一个错误,包括“张量不是这个图的一个元素”。
for modelLayer in mModel.layers:
if not modelLayer.output == mModel.input:
intermediateModel = keras.models.M
我正在通过tensorflow后端通过keras训练一些模型。
当我在同一对象上训练后立即调用predict时,它工作得很好,并为不同的输入提供了不同的值。但是,当我将模型保存到一个文件中,然后从另一个python会话加载它时,predict总是为不同的输入返回相同的值。
我使用ModelCheckpoint保存模型,然后使用load_model加载。我还尝试使用to_json和model_from_json函数将架构分别保存和加载到json文件中。示例代码:
保存零件
with open("model.json", "w") as textFile:
p
我正在学习DCGAN的这个教程,并试图从我保存的检查点恢复一个模型。但是当我尝试加载模型时,它给出了一个错误:
AssertionError: Nothing except the root object matched a checkpointed value. Typically this means that the checkpoint does not match the Python program. The following objects have no matching checkpointed value: [<tensorflow.python.keras.lay
我有大约120个模型训练并存储在多个文件夹中。我正在尝试将这些模型加载到字典中,以便做出特定于其用例的预测。 但问题是,由于字典变得太大,加载这些模型以及预测输出需要时间。 有没有比在python字典中更有效地加载这些模型的方法?我甚至尝试将这120个模型加载到12个不同的字典中,但加载和预测仍然需要大量的时间。 但问题是,由于字典变得太大,加载这些模型以及预测输出需要时间。 model = {}
for _ in tqdm(os.listdir("wts_deep")):
try:
int(_[0])
list_of_models =
#train model
#here is one sample
sample = validation_X[0].reshape(1, -1)
#print the sample for reference
print(sample)
#show the weights for reference
print(model.get_weights())
#show prediction
print(model.predict(sample))
#another prediction that is the same as above
print(model.predict(samp
我正在尝试使用拥抱面模型(),但是在加载令牌程序:代码时会出现错误:
from transformers import AutoTokenizer, AutoModelForMaskedLM
tokenizer = AutoTokenizer.from_pretrained("CAMeL-Lab/bert-base-arabic-camelbert-ca")
model = AutoModelForMaskedLM.from_pretrained("CAMeL-Lab/bert-base-arabic-camelbert-ca")
错误:
OSError: Ca