class: center, middle, agbg # Neural Spatial Curves
Press
P
for speaker notes
Text Version
By Mauve Signweaver
--- class: center, middle, agbg ## TODO: - Space Filling Curves - Auto-Encoders - Neural Spatial Curves - Improvements --- class: center, middle, agbg ### Space Filling Curves - Maps 1 Dimension to N Dimensions - Variable fidelity in mapping - Fractals --- class: center, middle, agbg ### Hilbert Curves `hilbertCurve(n) -> (X,Y)`  --- class: center, middle, agbg ### MATH  --- class: center, middle, agbg ### Can a Neural Network do it instead? - Smallest model possible - Incremental improvements - Interpret inner representation - Build intuition --- class: center, middle, agbg ## Auto Encoders - Train to output same as input - `Encoder` -> `Latent Space` -> `Decoder` - Hourglass Shape - Compress data to latent space - Encoder compresses points - Decoder is the spatial curve --- class: center, middle, agbg ## Structure  --- class: center, middle, agbg ## Initial Model ```python X = np.random.rand(1000, 2) input_layer = Input(shape=(2,)) hidden_layer_1 = Dense(64, activation='relu')(input_layer) # Bottleneck layer with one neuron hidden_layer_2 = Dense(1, activation='linear')(hidden_layer_1) hidden_layer_3 = Dense(64, activation='relu')(hidden_layer_2) output_layer = Dense(2)(hidden_layer_3) # Output layer autoencoder = Model(inputs=input_layer, outputs=output_layer) # Compile the model autoencoder.compile(optimizer='adam', loss='mean_squared_error') # Train the model autoencoder.fit(X, X, epochs=500, batch_size=32) ``` --- class: center, middle, agbg ## Mapping Internal Space  --- class: center, middle, agbg ## All ReLU Activations Fix: Linear activation as last layer  --- class: center, middle, agbg ## More Hidden Layers  = **More complexity** --- class: center, middle, agbg ## Batch Size ~~32~~ **256**  --- class: center, middle, agbg ## Batch Normalization  Normalized Inputs = Stabilized Training --- class: center, middle, agbg ## More neurons ~~2 -> 64 -> 32 -> 1 -> 32 -> 64 -> 2~~ `2 -> 128 -> 64 -> 1 -> 64 -> 128 -> 2`  --- class: center, middle, agbg ## Dropout Layers  Reducing complexity helps improve generalization. We kinda want the complexity here 😅 --- class: center, middle, agbg ## More Layers ~~128 -> 64~~ `256 -> 128 -> 64`  --- class: center, middle, agbg ## More Neurons!! ~~256 -> 128 -> 64~~ `512 -> 256 -> 128`  --- class: center, middle, agbg ## Mean Absolute Error Loss Function  - Better for nonlinear relationships - Robust to large variation in data --- class: center, middle, agbg ## Dynamic Learning Rate ```python ReduceLROnPlateau( monitor='loss', # Monitor loss # Epochs without improvement before learning rate is reduced patience=3, # Factor by which the learning rate will be reduced factor=0.5, # Minimum learning rate to prevent it from becoming too low min_lr=1e-6 ) ``` --- class: center, middle, agbg ## Reduce LR On Plateau Result  --- class: center, middle, agbg ## Way more epocs  --- class: center, middle, agbg ## Conclusions - Least Complex model "good enough" - Size / Depth makes a huge difference - Normalization can help with training - Linear activation at the end --- class: center, middle, agbg - Come chat [on matrix](https://matrix.to/#/#userless-agents:mauve.moe) - `contact@mauve.moe`