hnn-core
hnn-core copied to clipboard
Optimization with calcium model
Hello, I am following the optimization tutorial. My question is about the part of the code where you load in the parameter file. So I created my parameters using hnn-core and I don't know how to save them into a json parameter file. I tried to use the GUI to create the file, but then realized that the GUI uses the jones_2009_model and not the calcium_model which I used. Can you please tell me how to generate a parameter file using hnn-core?
I don't think we have a function to write these files out ... we really need to get to it soon. You can probably pickle it in the meanwhile but it's not a long-term solution.
Can we aim to hammer some of these long-lasting issues out in a sprint in Nov @chenghuzi @rythorpe @ntolley ? Would be good to start planning for it ...
Agreed, could plan to do it after SfN! (it ends November 16th).
Before may work depending on how much last minute poster making me and @rythorpe have to do
Okay, one more question how did you get the default.json parameter file that is being used in the parameter optimization example? Did you produce it with the GUI?
@JBruce32 the default parameter file comes from the parameter tuned network used in Jones et al. 2009
It's broadly the same structure as the .param
files from HNN-GUI (however a .json is written like a dictionary where all the elements is enclosed in curly braces).
We technically have a read_param()
function that works with .param
files, but as referenced above we are planning to move away from this for a more long term solution.
If there are specific values/properties you're looking to change you can check out the docs/examples or let us know! The current API allows you to modify any property defined in the .param file without editing the files directly.
Okay, so looking at the docs/examples I came across the hnn_core.params.write function. Here is a snippet:
def write(self, fname):
"""Write param values to a file.
Parameters
----------
fname : str
Full path to the output file (.json)
"""
with open(fname, 'w') as fp:
json.dump(self, fp)
Does this function allow me to store my model parameters in a json file at all? If so, how can I use this function given my network object?
Thanks
Hi @JBruce32, unfortunately this function is not used for writing the details of the Network
to a file (internally this function is useful for testing purposes).
For context, the .params
or .json
files are currently used to instantiate the model with default values in line with the old HNN-GUI. We're working on a good method/format to write the Network
parameters to a file, but for now I think the best solution will be to either: 1) Pickle the entire Network object, or 2) just store the code which contains your parameter modifications using the hnn-core API.
The parameters of the provided networks such as jones_2009_model()
and law_2021_model()
will not change, so if you just keep track of your specific parameter changes then that will be sufficient for reproducibility. Definitely let me know if you need help/guidance for the suggestions listed above.