Talos 1.0中调用best_model函数选择最优模型的语法错误问题咨询
best_model Hey there! Let's work through this Talos issue you're hitting— I’ve got you covered.
The core problem here is that talos.best_model() isn’t the right syntax for Talos 1.0+. Starting with version 1.0, Talos completely refactored its API: the best_model method is no longer a top-level function under the talos module. Instead, it’s a method that belongs directly to the Scan object you create when you run your hyperparameter scan.
Here’s the straightforward fix:
You already stored your scan results in the jam1 variable, so you just need to call best_model() on that instance, not the talos module itself. Your corrected code should look like this:
# Run your scan as you originally did jam1 = talos.Scan(data, labels[0,], model=DLAt, params=ParamsJam1, experiment_name="DL2Outputs") # Call best_model on the Scan instance you created bm = jam1.best_model(metric='loss', asc=False)
Why this error pops up:
In older Talos versions (pre-1.0), there was a top-level talos.best_model() function, but the 1.0 release reorganized the API to tie all scan-specific operations (like fetching the best model, best parameters, or analyzing results) directly to the Scan class. This makes the workflow more intuitive since all results are linked to the exact scan you ran.
Once you get the optimal model via jam1.best_model(), you can use it just like any other Keras model—for making predictions, saving it to disk, or doing further fine-tuning.
内容的提问来源于stack exchange,提问作者Jim Maas

