title: keras loss function(from keras input)
body: <p>I reference the link: <a href="https://stackoverflow.com/questions/46464549/keras-custom-loss-function-accessing-current-input-pattern">Keras custom loss function: Accessing current input pattern</a>.</p>
  <p>But I get error:  &quot;  TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. &quot;</p>
  <p>This is the source code:  What happened ?</p>
  <pre><code>def custom_loss_wrapper(input_tensor):
      def custom_loss(y_true, y_pred):
          return K.binary_crossentropy(y_true, y_pred) + K.mean(input_tensor)
      return custom_loss
  
  input_tensor = Input(shape=(10,))
  hidden = Dense(100, activation='relu')(input_tensor)
  out = Dense(1, activation='sigmoid')(hidden)
  model = Model(input_tensor, out)
  model.compile(loss=custom_loss_wrapper(input_tensor), optimizer='adam')
  
  X = np.random.rand(1000, 10)
  y = np.random.rand(1000, 1)
  model.train_on_batch(X, y)  
  </code></pre>