title: Use loss in the keras model function
body: <p>I am trying to build the a very simple model using keras using the Model function, like below, where the input and output of the Model function are [img,labels] and the loss.
  I am confused why this code is not working, if the output cannot be the loss. How should the Model function work and when should we use the Model function? Thanks.</p>
  
  <pre><code>sess = tf.Session()
  K.set_session(sess)
  K.set_learning_phase(1)
  img = Input((784,),name='img')
  labels = Input((10,),name='labels')
  # img = tf.placeholder(tf.float32, shape=(None, 784))
  # labels = tf.placeholder(tf.float32, shape=(None, 10))
  
  x = Dense(128, activation='relu')(img)
  x = Dropout(0.5)(x)
  x = Dense(128, activation='relu')(x)
  x = Dropout(0.5)(x)
  preds = Dense(10, activation='softmax')(x)
  
  from keras.losses import binary_crossentropy
  #loss = tf.reduce_mean(categorical_crossentropy(labels, preds))
  loss = binary_crossentropy(labels, preds)
  print(type(loss))
  model = Model([img,labels], loss, name='squeezenet')
  model.summary()
  </code></pre>