Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix train_from_presimulation for model comparison #92

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bayesflow/trainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import logging
import os
from pickle import load as pickle_load
import tensorflow as tf

import numpy as np
import tensorflow as tf
from tqdm.autonotebook import tqdm

from bayesflow.amortizers import (
Expand Down Expand Up @@ -737,7 +737,10 @@ def train_from_presimulation(
input_dict = self.configurator(epoch_data[index])

# Like the number of iterations, the batch size is inferred from presimulated dictionary or list
batch_size = epoch_data[index][DEFAULT_KEYS["sim_data"]].shape[0]
if isinstance(self.amortizer, AmortizedModelComparison):
batch_size = input_dict[DEFAULT_KEYS["summary_conditions"]].shape[0]
else:
batch_size = epoch_data[index][DEFAULT_KEYS["sim_data"]].shape[0]
loss = self._train_step(batch_size, _backprop_step, input_dict, **kwargs)

# Store returned loss
Expand Down
Loading