title: Unsupervised loss function in Keras
body: <p>Is there any way in Keras to specify a loss function which does not need to be passed target data?</p>
  
  <p>I attempted to specify a loss function which omitted the <code>y_true</code> parameter like so:</p>
  
  <pre><code>def custom_loss(y_pred):
  </code></pre>
  
  <p>But I got the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "siamese.py", line 234, in &lt;module&gt;
      model.compile(loss=custom_loss,optimizer=Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0))
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 911, in compile
      sample_weight, mask)
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 436, in weighted
      score_array = fn(y_true, y_pred)
  TypeError: custom_loss() takes exactly 1 argument (2 given)
  </code></pre>
  
  <p>I then tried to call <code>fit()</code> without specifying any target data:</p>
  
  <pre><code> model.fit(x=[x_train,x_train_warped, affines], batch_size = bs, epochs=1)
  </code></pre>
  
  <p>But it looks like not passing any target data causes an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "siamese.py", line 264, in &lt;module&gt;
      model.fit(x=[x_train,x_train_warped, affines], batch_size = bs, epochs=1)
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1435, in fit
      batch_size=batch_size)
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1322, in _standardize_user_data
      in zip(y, sample_weights, class_weights, self._feed_sample_weight_modes)]
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 577, in _standardize_weights
      return np.ones((y.shape[0],), dtype=K.floatx())
  AttributeError: 'NoneType' object has no attribute 'shape'
  </code></pre>
  
  <p>I could manually create dummy data in the same shape as my neural net's output but this seems extremely messy. Is there a simple way to specify an unsupervised loss function in Keras that I am missing?</p>