autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 268 forks source link

batch_size not support list #601

Open anxinyf opened 5 months ago

anxinyf commented 5 months ago

1) Confirm the below

2) Include the output of:

talos.__version__ 1.4

3) Explain what actually happened

keras version: 2.14.0

params={'batch_size': [10, 20, 30]}

def create_model(x_train, y_train, x_val, y_val, params):
    ...
    out = model.fit(x_train, y_train, batch_size=params['batch_size'])
    return out, model

talos.Scan(x=x_train, y=y_train,
                   model=create_model,
                   params=params,
                   experiment_name='build_model',
                   x_val=x_val, y_val=y_val)

log:

out = model.fit(x_train, y_train,
  File ".../lib/python3.9/site-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File ".../lib/python3.9/site-packages/keras/src/engine/data_adapter.py", line 275, in __init__
    self._size = int(math.ceil(num_samples / batch_size))
TypeError: unsupported operand type(s) for /: 'int' and 'list'
  0%|          | 0/192 [00:00<?, ?it/s]

when model.fit(batch_size=params['batch_size']), then 'batch_size' param not support list, even latest keras version v3.3.3:

batch_size: Integer or `None`.
                Number of samples per gradient update.
                If unspecified, `batch_size` will default to 32.
                Do not specify the `batch_size` if your data is in the
                form of datasets, generators, or `keras.utils.PyDataset`
                instances (since they generate batches).

Is there a problem with my configuration?


mikkokotila commented 5 months ago

@anxinyf there is nothing apparent from what you have shared above. Is it possible to share a google colab notebook which reproduce this issue?