I am trying to become familiar with BayesFlow by going through the example scripts. I installed the latest version of Bayesflow and just tried to run the Linear_Regression_Starter example right from the Juypter notebook. All of the code up to the point where I try to run the approximate.fit command. However, when I try to run “approximator.fit” command in the example, I get an error. It seems like it starts running the function okay, but then runs into an issue.
Again, I apologize if I am missing something simple.
history = approximator.fit(
epochs=epochs,
num_batches=num_batches,
batch_size=batch_size,
simulator=simulator,
)
INFO:bayesflow:Building dataset from simulator instance of SequentialSimulator.
INFO:bayesflow:Using 8 data loading workers.
INFO:bayesflow:Building on a test batch.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[76], line 1
----> 1 history = approximator.fit(
2 epochs=epochs,
3 num_batches=num_batches,
4 batch_size=batch_size,
5 simulator=simulator,
6 )
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/bayesflow/approximators/continuous_approximator.py:202, in ContinuousApproximator.fit(self, *args, **kwargs)
150 def fit(self, *args, **kwargs):
151 """
152 Trains the approximator on the provided dataset or on-demand data generated from the given simulator.
153 If `dataset` is not provided, a dataset is built from the `simulator`.
(...) 200 If both `dataset` and `simulator` are provided or neither is provided.
201 """
--> 202 return super().fit(*args, **kwargs, adapter=self.adapter)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/bayesflow/approximators/approximator.py:134, in Approximator.fit(self, dataset, simulator, **kwargs)
132 mock_data = dataset[0]
133 mock_data = keras.tree.map_structure(keras.ops.convert_to_tensor, mock_data)
--> 134 self.build_from_data(mock_data)
136 return super().fit(dataset=dataset, **kwargs)
...
1802 )
1803 expected_call_arg = utils.removesuffix(name, "_shape")
1804 if expected_call_arg not in call_spec.arguments_dict:
ValueError: For a `build()` method with more than one argument, all arguments should have a `_shape` suffix and match an argument from `call()`. E.g. `build(self, foo_shape, bar_shape)` For layer 'DeepSet', Received `build()` argument `self`, which does not end in `_shape`.
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...