Skip to content

3. Modifying the Network

EthanTreg edited this page Sep 18, 2024 · 2 revisions

The code is designed to try and be as general as possible; therefore, it should be very easy to change the architecture.

Manually Configuring the Network

The architecture for the decoder and encoder are under the network_configs directory and are saved as .json files.
The construction of the network uses the package developed separately called PyTorch-Network-Loader.
This enables the construction of neural networks using .json files and the training harnesses to easily train and generate predictions for different types of architectures.
See the Wiki for how to change the architecture.

Optimising Hyperparameters using Optuna (Not Supported)

Network optimisation using Optuna was implemented in an early state; however, after updating the code to use more recent versions of PyTorch-Network-Loader, the code has become out of date and no longer works.
In the future, PyTorch-Network-Loader may include better support for network optimisation using Optuna; however, at this stage, it requires manual implementation and rewriting the existing code.
The script for network optimisation is fspnet.network_optimizer.
It can save the optimisation progress and produce several plots to visualise the optimal hyperparameters.

Currently, only changing the learning rate, number of convolutional filters and convolutional layers in two parts in the network are supported.

The function optimize_network can be imported to integrate network optimisation.
optimize_network returns a dictionary containing the parameters from the best trial.

Several parameters in the network-optimizer config file need configuring:

  • optimization options:
    • name: name of the network to optimize
  • output options:
    • network-states-directory: path to the directory containing the network states

Example code

from fspnet.network_optimizer import optimize_network
from fspnet.spectrum_fit import init

loaders = init()[1]

optimize_network(config, loaders)

Clone this wiki locally