Slow-Fast Neural Engine Block for Advanced Feature Processing
Overview
SFNEBlock (Slow-Fast Neural Engine Block) combines slow and fast processing paths for feature extraction. It uses a SlowNetwork to generate hyper-kernels, which are then processed by a HyperZZWOperator to compute context-dependent weights. These weights are further processed through global and local convolutions before being combined. This architecture is designed as a building block for complex tabular data modeling tasks.
Key Features
Dual-Path Architecture: Slow and fast processing paths for multi-scale feature extraction
Hyper-Kernel Generation: SlowNetwork generates adaptive kernels for feature processing
Context-Dependent Weights: HyperZZWOperator computes dynamic weights based on input context
Multi-Scale Processing: Global and local convolutions capture different feature scales
# Small modelsmall_model=SFNEBlock(input_dim=16,output_dim=8,hidden_dim=32,num_layers=1,slow_network_layers=2,slow_network_units=64)# Large modellarge_model=SFNEBlock(input_dim=16,output_dim=8,hidden_dim=128,num_layers=3,slow_network_layers=4,slow_network_units=256)# Same input/output dimensionsame_dim_model=SFNEBlock(input_dim=16,output_dim=16,# Explicitly sethidden_dim=64)
With Preprocessing Model
1 2 3 4 5 6 7 8 91011121314
fromkerasfactory.utils.data_analyzerimportDataAnalyzerimportpandasaspd# Create preprocessing modeldf=pd.DataFrame(np.random.randn(100,16))analyzer=DataAnalyzer(df)preprocessing_model=analyzer.create_preprocessing_model()# Create model with preprocessingmodel=SFNEBlock(input_dim=16,output_dim=8,preprocessing_model=preprocessing_model)
Feature Extraction
1 2 3 4 5 6 7 8 910
# Use as feature extractorfeature_extractor=SFNEBlock(input_dim=64,output_dim=32,# Reduced dimensionhidden_dim=128)# Extract featuresfeatures=feature_extractor(X_train)print(features.shape)# (100, 32)
Serialization
1 2 3 4 5 6 7 8 9101112
# Save modelmodel.save('sfne_block_model.keras')# Load modelloaded_model=keras.models.load_model('sfne_block_model.keras')# Save weights onlymodel.save_weights('sfne_block_weights.h5')# Load weightsmodel_new=SFNEBlock(input_dim=16,output_dim=8)model_new.load_weights('sfne_block_weights.h5')
Best Use Cases
Feature Extraction: Advanced feature processing for tabular data
Building Block: Component for larger architectures (e.g., TerminatorModel)
Complex Feature Interactions: When you need multi-scale feature processing
Adaptive Processing: When feature processing should adapt to input context