title: one-hot encoding of an array of floats using just keras
body: <p>First of, I am new to stackoverflow, so if there is a way to improve the way I formulate my question or if I missed something obvious, do point it out to me please!</p>
  
  <p>I am building a classification convolutional network in Keras, where the network is asked to predict parameter was used to generate the image. The classes are encoded in 5 float values, e.g. a list of the classes may look like this:</p>
  
  <pre><code>[[0.], [0.76666665], [0.5], [0.23333333], [1.]]
  </code></pre>
  
  <p>I want to one-hot encode these classes, using the <code>keras.utils.to_categorical(y, num_classes=5, dtype='float32')</code> function.</p>
  
  <p>However, it returns the following:</p>
  
  <pre><code>array(
      [
         [1., 0., 0., 0., 0.],
         [1., 0., 0., 0., 0.],
         [1., 0., 0., 0., 0.],
         [1., 0., 0., 0., 0.],
         [0., 1., 0., 0., 0.]
      ], 
  dtype=float32)
  </code></pre>
  
  <p>It only takes integers as input, thus it maps all values <code>&lt; 1.</code> to <code>0</code>.
  I could circumvent this by multiplying all values with a constant so they are all integers and I think there is also a way to solve this problem within scikit learn, but that sounds like a huge work-around for a problem that should be trivial to solve within just keras, which makes me believe I am missing something obvious.</p>
  
  <p>I hope somebody is able to point out a simple alternative using just Keras.</p>