OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Pytorch2Keras

Pytorch2Keras is a Python library that converts PyTorch model graphs into Keras models using TensorFlow as the Keras backend.

Independent OpenViST project profile, based on linked sources.

Pytorch2Keras — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

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.
Before you choose

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.

Source-based practical guide

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

  1. Install the package with the command below.

    Documented command
    pip install pytorch2keras
  2. Configure ~/.keras/keras.json to use the TensorFlow backend and channels-first image data format.

  3. Create a dummy input variable with the model's input dimensions.

  4. Call pytorch_to_keras with the model, dummy input variable and input shape; the documented example stores the returned model in k_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.
Evidence and transparency

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