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


Release history Release notifications | RSS feed

Download files

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

Source Distribution

keras_data_format_converter-0.1.24.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keras_data_format_converter-0.1.24-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file keras_data_format_converter-0.1.24.tar.gz.

File metadata

File hashes

Hashes for keras_data_format_converter-0.1.24.tar.gz
Algorithm Hash digest
SHA256 54637106a010503d0c8c038de01a1544ee2fe252aadd4a77c0f5a8c13bcf48e7
MD5 6c9fb51f70e49ee07e4113e6d07a3010
BLAKE2b-256 e17fd3cce9994c286aa9af57744358ceac2921d348e36b96eaa07f06a79beee2

See more details on using hashes here.

File details

Details for the file keras_data_format_converter-0.1.24-py3-none-any.whl.

File metadata

File hashes

Hashes for keras_data_format_converter-0.1.24-py3-none-any.whl
Algorithm Hash digest
SHA256 1e78aa5fdd766526e200205a49d10e3e0e17a9fd0eaacdfb24a94fb4f7b88d34
MD5 1cabef59781b5aa83d423dba88bcf8c3
BLAKE2b-256 6bea291eef5273c846585c3416acc3d9076d6c498ae7cc6a5a570c46fc0ec600

See more details on using hashes here.

Supported by

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