Skip to content

Commit 40a39d9

Browse files
authored
Add support for many additional Keras 3 layers (#465)
Restores the recurrent layers (LSTM, GRU, SimpleRNN, Bidirectional) that were removed when Keras 3 broke the previous implementation, and adds a broad set of Keras-3-era layers that had been listed as unsupported: - LSTM, GRU, SimpleRNN, Bidirectional (all merge_modes) - ConvLSTM1D/2D/3D - 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) - Many training-only Random*/AugMix/etc. image augmentation passthroughs
1 parent 02eb663 commit 40a39d9

23 files changed

Lines changed: 2866 additions & 21 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/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace internal {
8080
using RowMajorMatrixXf = Eigen::Matrix<float_type, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
8181
using ArrayXf = Eigen::Array<float_type, Eigen::Dynamic, Eigen::Dynamic>;
8282
using ArrayXf1D = Eigen::Array<float_type, Eigen::Dynamic, 1>;
83-
using MappedRowMajorMatrixXf = Eigen::Map<RowMajorMatrixXf, Eigen::Aligned>;
83+
using MappedRowMajorMatrixXf = Eigen::Map<const RowMajorMatrixXf, Eigen::Unaligned>;
8484

8585
inline float_type tanh_typed(float_type x)
8686
{

0 commit comments

Comments
 (0)