Skip to main content

Generates equal keras models with the desired data format

Project description

Keras data format converter

Generates equal keras models with the desired data format

Requirements

tensorflow >= 2.0

API

convert_channels_first_to_last(model: keras.Model, inputs_to_transpose: List[str] = None, verbose: bool = False) -> keras.Model

convert_channels_last_to_first(model: tf.keras.Model, inputs_to_transpose: List[str] = None, verbose: bool = False) \ -> tf.keras.Model

model: Keras model to convert

inputs_to_transpose: list of input names that need to be transposed due tothe data foramt changing

verbose: detailed output

Getting started

from tensorflow import keras
from keras_data_format_converter import convert_channels_last_to_first

# Load Keras model
keras_model = keras.models.load_model("my_image_model")

# Call the converter (image_input is an input that needs to be transposed, can be different for your model)
converted_model = convert_channels_last_to_first(keras_model, ["image_input"])

Supported Layers with Special handling

  • Normalization layers
  • Permute
  • Reshape
  • Concatenate
  • Dot
  • MultiHeadAttention
  • TFOpLambda (Inserted by the Functional API construction whenever users call a supported TF symbol on KerasTensors, see here at Tensorflow repo for more info)

Unsupported Layers due to lack of data_format property

  • Cropping1D
  • Upsampling1D
  • Zeropadding1D
  • All layers in tensorflow.keras.preprocessing

How to deploy

  • Create a new release version on GitHub
  • Update parameters in setup.py (usually version and download_url)
  • Run python setup.py sdist in root directory
  • Run pip install twine
  • Run twine upload dist/*

License

This software is covered by MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorleap-0.0.4.tar.gz (20.4 kB view details)

Uploaded Source

File details

Details for the file tensorleap-0.0.4.tar.gz.

File metadata

  • Download URL: tensorleap-0.0.4.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.7

File hashes

Hashes for tensorleap-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2ee4148e9d1ec60c03d5055371bcc0e65125bb5d550c97ee434b17bf62a312fc
MD5 dda80dc0e2c25aaf06a518b4745437e9
BLAKE2b-256 38ba24b2657ae3341d354ec2318851dff19fd071568879d062b9a71162b18b27

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page