[英]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.