VGSLify v0.14.0 Release Notes
Summary
This release adds the ability to register and parse custom layers for both TensorFlow and PyTorch backends in VGSLify. It also introduces a few breaking changes related to file organization and simplifies import paths to make the library easier to use.
New Features
-
Custom Layer Registration (TensorFlow and PyTorch)
-
You can now register custom layer builder functions directly with the
TensorFlowLayerFactory(and similarly with the Torch layer factory).from vgslify.tensorflow import TensorFlowLayerFactory @classmethod def register(cls, prefix: str, builder_fn): ...
-
Alternatively, use the new decorator approach:
from vgslify.tensorflow import register_custom_layer @register_custom_layer("Xsw") def build_custom_layer(factory, spec): # Custom layer logic return tf.keras.layers.Dense(10)
-
This allows users to incorporate any custom TensorFlow or PyTorch layers into a VGSL specification simply by providing a prefix and builder function.
-
-
Custom Parser Registration for Model -> Spec
-
To convert a custom layer back into a VGSL specification, you can now register parser functions:
from vgslify.model_parsers.tensorflow import register_custom_parser import tensorflow as tf class MyCustomLayer(tf.keras.layers.Layer): def __init__(self, units: int): super().__init__() self.units = units @register_custom_parser(MyCustomLayer) def parse_my_custom_layer(layer: MyCustomLayer): return f"MyCustomSpec({{layer.units}})"
-
These functions are then picked up automatically by the parser (
TensorFlowModelParserorTorchModelParser) to handle custom layers.
-
Breaking Changes
-
Module Renaming and Reorganization
vgslify.parsersis nowvgslify.model_parsers.tf_parser.py,torch_parser.py, andbase_parser.pyhave been reorganized intotensorflow/,torch/, andbase/directories respectively.vgslify.core.parseris now calledvgslify.core.spec_parser.
-
Simplified Imports
-
You can now import the main classes and utilities more directly:
from vgslify import VGSLModelGenerator, model_to_spec
-
Parser imports have been simplified:
from vgslify.tensorflow import TensorFlowModelParser from vgslify.torch import TorchModelParser
-
Layer factory imports have also been unified:
from vgslify.tensorflow import TensorFlowLayerFactory, register_custom_layer
-
Example Usage
from vgslify import VGSLModelGenerator, model_to_spec
from vgslify.tensorflow import register_custom_layer
from vgslify.model_parsers.tensorflow import register_custom_parser
# Register a custom layer builder
@register_custom_layer("Xsw")
def my_custom_builder(factory, spec):
# Implement custom layer creation here
return tf.keras.layers.Dense(10)
# Register a custom parser for that layer
@register_custom_parser(MyCustomLayer)
def my_custom_parser(layer):
# Return the spec string for this custom layer
return f"Xsw({{layer.units}})"
# Example model creation and spec conversion
model = ...
vgsl_spec = model_to_spec(model)Additional Changes
- Updated the documentation with advanced examples.
- Allow installation of the latest version of the desired backend with
vgslify[torch]orvgslify[tensorflow]. - Fixed a bug where the TensorFlow model parser could not handle pooling layers.