Practical overview
When it fits
Use it when you have a PyTorch model and want a Keras representation, and can check the model's operations against the listed layer support before relying on conversion.
Who it is for
- Machine-learning developers moving a PyTorch model into a Keras-based workflow.
- Teams assessing a model migration, provided its operations fit the converter's documented layer coverage.
Documented uses
- Trace a PyTorch model using a correctly shaped dummy input and convert it to a Keras model.
- Check documented layer support when assessing a model migration.
- Prepare a converted Keras model for a TensorFlow.js export workflow using short layer names.
Requirements & limits
The repository is public, identifies the project as open source under the MIT license, and documents installation with pip.
- Conversion uses tracing with a dummy input, so its dimensions must match the model input.
- Keras must be configured with the TensorFlow backend and channels-first image data format, according to the README.
- The README lists supported layer types, but does not claim complete PyTorch operation coverage.
- The TensorFlow.js notes specify short layer names and warn that one described export route may not work in some cases.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Convert a PyTorch model into a Keras model
Prepare a Keras model from a PyTorch model using the documented tracing workflow.
Before you start
- A valid PyTorch model.
- A dummy input variable with dimensions appropriate to the model.
- Keras configured with the TensorFlow backend and channels-first image data format.
- The pytorch2keras package, installed with pip.
Steps
Install the package with the command below.
pip install pytorch2kerasConfigure
~/.keras/keras.jsonto use the TensorFlow backend and channels-first image data format.Create a dummy input variable with the model's input dimensions.
Call
pytorch_to_keraswith the model, dummy input variable and input shape; the documented example stores the returned model ink_model.
Expected outcome
The converter returns a Keras model in `k_model` when the model's modules convert properly.
Guide limitations
- The README makes successful conversion conditional on the model's modules converting properly.
- The documentation does not specify runtime requirements or broad model-conversion coverage.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 5 November 2026
- Original website title
- gmalivenko/pytorch2keras · Official homepage title · retained in its source language

