Skip to content

Commit 2309fdd

Browse files
Dobiasdclaude
andcommitted
Add support for many additional Keras 3 layers
Restored recurrent layers (LSTM, GRU, SimpleRNN, Bidirectional) that were removed in commit a60717c when Keras 3 broke the previous implementation, and added a broad set of layers that had been listed as unsupported. New layers: - LSTM, GRU, SimpleRNN, Bidirectional (all merge_modes) - ConvLSTM1D, ConvLSTM2D, ConvLSTM3D - RNN wrapping LSTMCell / GRUCell / SimpleRNNCell / StackedRNNCells - EinsumDense (generic einsum interpreter) - GroupedQueryAttention (with optional use_gate) - AdaptiveAvg/MaxPooling 1D/2D/3D - DepthwiseConv1D - RMSNormalization, GroupNormalization - Discretization, IntegerLookup - Masking (passthrough; mask propagation through recurrent layers is not modeled) - Many training-only image-augmentation layers as identity passthroughs (RandomBrightness, RandomCrop, RandomHue, AugMix, CutMix, MixUp, RandAugment, AutoContrast, etc.) Caveats: - Stateful recurrent layers and return_state-as-input remain unsupported. - ConvLSTM go_backwards / unroll / stateful remain unsupported. - GroupNormalization currently only supports axis=-1. A new test_model_recurrent test target exercises each new layer with multiple distinct configurations. README: pruned stale unsupported entries (ThresholdedReLU, LocallyConnected1D/2D, CuDNNGRU/LSTM) that were removed in Keras 3. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 02eb663 commit 2309fdd

23 files changed

Lines changed: 2724 additions & 20 deletions

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,31 @@ Would you like to build/train a model using Keras/Python? And would you like to
4141

4242
* `Add`, `Concatenate`, `Subtract`, `Multiply`, `Average`, `Maximum`, `Minimum`, `Dot`
4343
* `AveragePooling1D/2D/3D`, `GlobalAveragePooling1D/2D/3D`
44+
* `AdaptiveAveragePooling1D/2D/3D`, `AdaptiveMaxPooling1D/2D/3D`
4445
* `TimeDistributed`
45-
* `Conv1D/2D/3D`, `SeparableConv2D`, `DepthwiseConv2D`
46+
* `Conv1D/2D/3D`, `SeparableConv2D`, `DepthwiseConv1D`, `DepthwiseConv2D`
4647
* `Conv1DTranspose`, `Conv2DTranspose`, `Conv3DTranspose`
4748
* `Cropping1D/2D/3D`, `ZeroPadding1D/2D/3D`, `CenterCrop`
48-
* `BatchNormalization`, `Dense`, `Flatten`, `Normalization`
49+
* `BatchNormalization`, `Dense`, `EinsumDense`, `Flatten`, `Normalization`
4950
* `Dropout`, `AlphaDropout`, `GaussianDropout`, `GaussianNoise`
5051
* `SpatialDropout1D`, `SpatialDropout2D`, `SpatialDropout3D`
51-
* `ActivityRegularization`, `LayerNormalization`, `UnitNormalization`
52-
* `RandomContrast`, `RandomFlip`, `RandomHeight`
53-
* `RandomRotation`, `RandomTranslation`, `RandomWidth`, `RandomZoom`
52+
* `ActivityRegularization`, `LayerNormalization`, `RMSNormalization`
53+
* `GroupNormalization`, `UnitNormalization`
54+
* Training-only image augmentation layers (passed through at inference):
55+
`RandomBrightness`, `RandomContrast`, `RandomCrop`, `RandomFlip`, `RandomHue`,
56+
`RandomGrayscale`, `RandomRotation`, `RandomTranslation`, `RandomZoom`,
57+
`RandomShear`, `RandomSaturation`, `RandomPerspective`, `AutoContrast`,
58+
`AugMix`, `CutMix`, `MixUp`, `RandAugment`, `Solarization`, `Equalization`
5459
* `MaxPooling1D/2D/3D`, `GlobalMaxPooling1D/2D/3D`
5560
* `UpSampling1D/2D/3D`, `Resizing`, `Rescaling`
5661
* `Reshape`, `Permute`, `RepeatVector`
5762
* `Embedding`, `CategoryEncoding`
58-
* `Attention`, `AdditiveAttention`, `MultiHeadAttention`
63+
* `Discretization`, `IntegerLookup`
64+
* `Masking` (passthrough at inference)
65+
* `Attention`, `AdditiveAttention`, `MultiHeadAttention`, `GroupedQueryAttention`
66+
* `LSTM`, `GRU`, `SimpleRNN`, `Bidirectional`
67+
* `RNN` wrapping `LSTMCell`/`GRUCell`/`SimpleRNNCell`/`StackedRNNCells`
68+
* `ConvLSTM1D`, `ConvLSTM2D`, `ConvLSTM3D`
5969

6070
### Also supported
6171

@@ -71,15 +81,11 @@ Would you like to build/train a model using Keras/Python? And would you like to
7181
### Currently not supported are the following:
7282

7383
`Lambda` ([why](FAQ.md#why-are-lambda-layers-not-supported)),
74-
`ConvLSTM1D`, `ConvLSTM2D`, `Discretization`,
75-
`GRUCell`, `Hashing`,
76-
`IntegerLookup`,
77-
`LocallyConnected1D`, `LocallyConnected2D`,
78-
`LSTMCell`, `Masking`,
79-
`RepeatVector`, `RNN`, `SimpleRNN`,
80-
`SimpleRNNCell`, `StackedRNNCells`, `StringLookup`, `TextVectorization`,
81-
`Bidirectional`, `GRU`, `LSTM`, `CuDNNGRU`, `CuDNNLSTM`,
82-
`ThresholdedReLU`, `temporal` models
84+
`Hashing`, `HashedCrossing`,
85+
`MelSpectrogram`, `STFTSpectrogram`,
86+
`StringLookup`, `TextVectorization`,
87+
stateful recurrent layers,
88+
`temporal` models
8389

8490
Usage
8591
-----

include/fdeep/fdeep.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include "fdeep/convolution.hpp"
1212
#include "fdeep/filter.hpp"
1313
#include "fdeep/node.hpp"
14-
#include "fdeep/recurrent_ops.hpp"
1514
#include "fdeep/shape2.hpp"
1615
#include "fdeep/shape3.hpp"
1716
#include "fdeep/tensor.hpp"
1817
#include "fdeep/tensor_pos.hpp"
1918
#include "fdeep/tensor_shape.hpp"
2019
#include "fdeep/tensor_shape_variable.hpp"
20+
#include "fdeep/recurrent_ops.hpp"
2121

2222
#include "fdeep/import_model.hpp"
2323

0 commit comments

Comments
 (0)