Choose a dimensionality reduction method
masterTo project the high-dimensional optimization path into a 2D plane, you can specify a reduction_method.
"pca"(Default): Uses Principal Component Analysis to find the two orthogonal directions with the most variance. This is recommended for showing the most motion in 2D."random": Picks two random directions. Note that in high-dimensional space, these are likely to be orthogonal and may result in a visualization that looks like a random walk."custom": Allows you to provide two specific directions via thecustom_directionsparameter.
# Using random directions
loss_landscape_anim(n_epochs=300, load_model=False, reduction_method="random")
# Using custom directions
import numpy as np
n_params = ... # number of parameters your model has
u_gen = np.random.normal(size=n_params)
u = u_gen / np.linalg.norm(u_gen)
v_gen = np.random.normal(size=n_params)
v = v_gen / np.linalg.norm(v_gen)
loss_landscape_anim(
n_epochs=300,
load_model=False,
reduction_method="custom",
custom_directions=(u, v)
)