- This is the function signature : sbi.inference.base.infer(simulator, prior, method, num_simulations, num_workers=1).
- It requires an input theta ‘θ’ to run.
- Visit the below link to get more details: https://web.archive.org/web/20210621214049/https://www.mackelab.org/sbi/reference/
Use python sbi package in matlab, matlab give error: Python Error: TypeError: simulator() missing 1 required positional argument: 'parameter_set'
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to use python package sbi https://github.com/mackelab/sbi. Here is my matlab to perfom the experiment in https://www.mackelab.org/sbi/tutorial/00_getting_started/
clc;clear;
np = py.importlib.import_module('numpy');
torch = py.importlib.import_module('torch');
sbi = py.importlib.import_module('sbi');
%%
num_dim = int64(3);
low = -2*torch.ones(num_dim);
high = 2*torch.ones(num_dim);
prior = py.sbi.utils.BoxUniform(low, high);
posterior = py.sbi.inference.base.infer(py.test.simulator, prior, method='SNPE', num_simulations=1000)
My simulator function is test.py
def simulator(parameter_set):
return 1.0 + parameter_set + torch.randn(parameter_set.shape) * 0.1
The matlab give error Python Error: TypeError: simulator() missing 1 required positional argument: 'parameter_set'.
However, in python, it requires no input, but Matlab seems need one. Can anyone help?
0 个评论
回答(1 个)
Anjaneyulu Bairi
2023-11-9
I understand that you are getting an error related to python arguments which is a TypeError.
I was able to reproduce the same issue and tried to check the signature of the function and noted down some points on the simulator function
Hope it helps to resolve the query.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!