'matlab uses callable python function but require input
I am facing some problems to call python on Matlab. Here is my Matlab code
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)
I am using sbi package, which you can find here https://github.com/mackelab/sbi/tree/bb6150e54a0ba2e7c15432d52f53c130ced2a63c
Here is my python code in test.py
import torch
from sbi import utils as utils
from sbi import analysis as analysis
from sbi.inference.base import infer
def simulator(parameter_set):
return 1.0 + parameter_set + torch.randn(parameter_set.shape) * 0.1
when I run Matlab code, it gives an error: Python Error: TypeError: simulator() missing 1 required positional argument: 'parameter_set'. However, in the example of sbi https://www.mackelab.org/sbi/tutorial/00_getting_started/, it seems not need input for the simulator. Anyone can help?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
