简体   繁体   English

我如何从 python 中的预训练 model 中获取重量并在 tensorflow 中使用它?

[英]how can i get weight from a pretrained model in python and use it in tensorflow?

How can I get weights from a pre-trained model in PyTorch and use it in TensorFlow?如何从 PyTorch 中的预训练 model 中获取权重并在 TensorFlow 中使用它?

this is the pre-trained model:这是预训练的 model:

lstm = torch.hub.load("BruceWen120/medal", "lstm")

It is as of now not possible to convert PyTorch code into Tensorflow.目前无法将 PyTorch 代码转换为 Tensorflow。 (That is a transpiler to convert code written to train in one framework into another is not available). (这是一个将编写为在一个框架中训练的代码转换为另一个框架的转译器不可用)。 The reason is because training code is written in different ways in both libraries.原因是因为训练代码在两个库中以不同的方式编写。

However if model trained in one library is available, you can use it in the other.但是,如果在一个库中训练的 model 可用,您可以在另一个库中使用它。 The reason in that neural networks use standardized components which can be 1-to-1 corresponded between different frameworks.原因在于神经网络使用标准化组件,可以在不同框架之间一对一对应。

ONNX: Open Neural Network Exchange Format is a bridge format to transfer trained models between libraries. ONNX:开放神经网络交换格式是一种在库之间传输训练模型的桥梁格式。

While PyTorch supports onnx out of the box, Tensorflow can be connected by a open source connector too.虽然 PyTorch 支持开箱即用的 onnx,但 Tensorflow 也可以通过开源连接器连接。 ONNX: Open Neural Network Exchange Format ONNX:开放神经网络交换格式

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow:如何使用来自另一个 Tensorflow 模型的输入获得预训练 Keras 模型的正确输出 - Tensorflow: How to get the correct output of a pretrained Keras model with inputs from another Tensorflow model Tensorflow:使用预训练的初始模型 - Tensorflow: use pretrained inception model 如何使用预训练的gensim skipgram模型嵌入? - How can I use a pretrained embedding to gensim skipgram model? 如何使用keras从OpenCV的VideoCapture预测预训练模型? - How can I use keras to predict on a pretrained model from the VideoCapture of OpenCV? 如何使用Tensorflow的实例分割预训练的MaskRCNN模型? - How to use Instance segmentation pretrained MaskRCNN model by Tensorflow? 如何使用 Tensorflow 对象检测 api 评估预训练模型的准确性? - How to get the accuracy from the evaluation of a pretrained model using Tensorflow object detection api? 如何在Tensorflow中使用预训练的Word2Vec模型 - How to use pretrained Word2Vec model in Tensorflow 如何将预训练的 Tensorflow model 从 Google Cloud Storage 加载到 Datalab - How to load pretrained Tensorflow model from Google Cloud Storage into Datalab 当我尝试为我的预训练 model #python #nontype not callable 运行使用标记器时,我会出现此错误 - I can this error when I try to run use tokenizer for my pretrained model #python #nontype not callable 我可以在 keras model 在 Tensorflow 联邦学习 (TFF) 中使用 class_weight - Can I use class_weight in keras model in Tensorflow Federated Learning (TFF)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM