config a neural network with a JSON file
I want to config a neural network model (number of layers, number of neurons per layer, activation functions, ...) from a JSON file. But honestly, I have no idea how to do it. When I search the internet with &quot;hyperparameters config PyTorch&quot; or &quot;hyperparameters tunning PyTorch&quot; can't find anything interesting. The search result is more about hyperparameters optimization, not config from JSON.
Anyone has any idea how to do this (JSON file config) or do you know any useful tutorials that I can watch/read, please? That would be a great help!
Thank you in advance

Write your parameters to json file with proper name like following
{
   &quot;number_layers&quot;:1,
   &quot;number_neurons&quot;:2,
   &quot;activation_function&quot;:&quot;relu&quot;,
   &quot;training&quot;:{
      &quot;learning_rate&quot;:0.01
   }
}

Then read the json file
import json


with open('xxx.json', 'r', encoding='utf-8') as f:
    config = json.loads(f.read())

and access the parameter you want with
config['number_layers']
config['training']['learning_rate']

