If you define batch_size before initializing your model, such as:
batch_size = hp.Int('batch_size', min_value=1, max_value=10, step=16) model = Sequential()
then it works.