title: ERROR:The first argument to `Layer.call` must always be passed
body: <p>I am using <a href="/questions/tagged/tf.keras" class="post-tag" title="show questions tagged &#39;tf.keras&#39;" rel="tag">tf.keras</a> version 2.5.0.</p>
  <p>I defined my sequence of layers for a regression problem as a function, to be wrapped using the <strong>KerasRegressor</strong> class. This was done to allow me to perform a <strong>RandomizedSearchCV</strong>.</p>
  <pre><code>import os
  import tensorflow as tf
  import tensorflow_addons as tfa
  from tensorflow.keras import Sequential
  from tensorflow.keras.layers import Dense, Dropout
  from tensorflow.keras.layers import Input, InputLayer
  from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint, TensorBoard
  from keras.wrappers.scikit_learn import KerasRegressor
  from sklearn.model_selection import RandomizedSearchCV
  
  def build_model(n_hidden = 1, n_neurons = 32, input_shape = (X_train.shape[1],), dropout = 0):
    model = Sequential()
    model.add(InputLayer(input_shape = input_shape))
    for i in range(n_hidden):
      model.add(Dense(n_neurons, activation = 'relu'))
      model.add(Dropout(dropout))
    model.add(Dense(1))
    model.compile(loss = 'mean_squared_error', optimizer = 'adam', metrics = [tfa.metrics.RSquare(y_shape=(1,))])
    return model
  
  keras_reg = KerasRegressor(build_fn = build_model)
  
  history = keras_reg.fit(X_train, y_train, epochs = 200, batch_size = 64, 
                validation_data = (X_valid, y_valid),
                callbacks = callbacks)
  mse_test = keras_reg.score(X_test, y_test)
  
  
  </code></pre>
  <p>The code above works. However, when I try to define another KerasRegressor called keras_reg_A, and override the defaults for build_model, I get the error &quot;The first argument to <code>Layer.call</code> must always be passed&quot; (I left the callbacks out on purpose)</p>
  <pre><code>build_model_A = build_model(n_hidden = 2, n_neurons = 64, input_shape = (X_train.shape[1],), dropout = 0)
  keras_reg_A = KerasRegressor(build_model_A)
  
  history_A = keras_reg_A.fit(X_train, y_train, epochs = 200, batch_size = 64, 
                validation_data = (X_valid, y_valid))
  mse_test = keras_reg_A.score(X_test, y_test)
  
  </code></pre>
  <p>Can someone please explain why this is?</p>