title: ValueError: could not convert string to float: 'horse'
body: <p>I am working one Keras CIFAR10 Learning experiment, and the images got them from Kaggle, which is a CSV file with two columns, on 'id', the other 'label'. from here I do this. I know that I need to convert my labels to tensors, but don't know how to do it. I looked in the internet everywhere of how, but couldn't find anything that deals with reading CSV file from kaggle. Maybe this is not the way to do this....</p>
  
  <p>here is the link <a href="https://www.kaggle.com/c/cifar-10" rel="nofollow noreferrer">https://www.kaggle.com/c/cifar-10</a> but there are not kernels as an example.</p>
  
  <p>Thanks in advance for your help.</p>
  
  <p>I am using from tensorflow.keras.xxxxxx</p>
  
  <pre><code>import pandas as pd
  print("Image IDs and Labels (TRAIN)")
  train_df = pd.read_csv(TRAIN_DF_PATH)
  
  # Add extension to id_code to train images
  train_df['id'] = train_df['id'].apply(str) + ".png"
  
  display(train_df.head())
  
  def preprocess_image(path, sigmaX=40):
      """
      The whole preprocessing pipeline:
      1. Read in image
      3. Resize image to desired size
      """
      image = cv2.imread(path)
      image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
      image = cv2.resize(image, (IMG_WIDTH, IMG_HEIGHT))
  
      return image
  
  # Add Image augmentation to our generator
  train_datagen = ImageDataGenerator(rotation_range=360,
                                     horizontal_flip=True,
                                     vertical_flip=True,
                                     validation_split=0.25,
                                     rescale=1. / 255)
  
  # Use the dataframe to define train and validation generators
  train_generator = train_datagen.flow_from_dataframe(train_df, 
                                                      x_col='id', 
                                                      y_col='label',
                                                      directory = TRAIN_IMG_PATH,
                                                      target_size=(IMG_WIDTH, IMG_HEIGHT),
                                                      batch_size=BATCH_SIZE,
                                                      class_mode='other',
                                                      preprocessing_function=preprocess_image, 
                                                      subset='training')
  
  val_generator = train_datagen.flow_from_dataframe(train_df, 
                                                    x_col='id', 
                                                    y_col='label',
                                                    directory = TRAIN_IMG_PATH,
                                                    target_size=(IMG_WIDTH, IMG_HEIGHT),
                                                    batch_size=BATCH_SIZE,
                                                    class_mode='other',
                                                    preprocessing_function=preprocess_image, 
                                                    subset='validation')
  
  Batch_Size  = 64
  epochs      = 25
  
  # loop over the number of models to train
  for i in np.arange(0, 5):
  
      # initialize the optimizer and model
      print("[INFO] training model {}/{}".format(i + 1, 5))
      opt = Adam(lr=1e-5)
  
      conv_base = ResNet50(weights='imagenet', include_top=False, input_shape=(32, 32, 3))
  
      model = models.Sequential()
      model.add(conv_base)
      model.add(layers.UpSampling2D((2,2)))
      model.add(layers.UpSampling2D((2,2)))
      model.add(layers.UpSampling2D((2,2)))
      model.add(layers.Flatten())
      model.add(layers.BatchNormalization())
      model.add(layers.Dense(128, activation='relu'))
      model.add(layers.Dropout(0.5))
      model.add(layers.BatchNormalization())
      model.add(layers.Dense(64, activation='relu'))
      model.add(layers.Dropout(0.5))
      model.add(layers.BatchNormalization())
      model.add(layers.Dense(10, activation='softmax'))
  
      early_stop = EarlyStopping('val_loss', patience=5)
      reduce_lr = ReduceLROnPlateau('val_loss', factor=0.01, patience=3, verbose=1)
  
      ############################################################################
      trained_models_path = './best_model_adam/'
      model_names = trained_models_path + 'epoch_{epoch:02d}_val_acc_{val_acc:.4f}_'
      model_checkpoint = ModelCheckpoint(model_names +"model_{}.hdf5".format(i), verbose=1, save_best_only=True)
      ############################################################################
  
      callbacks = [model_checkpoint, early_stop, reduce_lr]
  
      #model.compile(optimizer=optimizers.RMSprop(lr=2e-5), loss='binary_crossentropy', metrics=['acc'])
      model.compile(optimizer=Adam(lr=1e-5), loss='binary_crossentropy', metrics=['acc'])
  
      # train the network
      history = model.fit_generator(
                              train_generator,
                              epochs = epochs,
                              steps_per_epoch= train_df.shape[0] // Batch_Size,
                              validation_data= val_generator,
                              validation_steps = val_generator.shape[0] // Batch_Size,
                              #batch_size = Batch_Size, 
                              verbose=1,
                              callbacks = [model_checkpoint, early_stop]
                          )
  
      # save the model to disk
      p = ["./models/model_{}.model".format(i)]
      model.save(os.path.sep.join(p))
  
      # evaluate the network
      predictions = model.predict(testX, batch_size=64)
      report = classification_report(testY.argmax(axis=1), predictions.argmax(axis=1), target_names=labelNames)
  
      # save the classification report to file
      p = ["./output/model_{}.txt".format(i)]
      f = open(os.path.sep.join(p), "w")
      f.write(report)
      f.close()
  </code></pre>
  
  <p>When I run the fit_generator I get his error</p>
  
  <pre><code>/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py in constant(value, dtype, shape, name)
      244   """
      245   return _constant_impl(value, dtype, shape, name, verify_shape=False,
  --&gt; 246                         allow_broadcast=True)
      247 
      248 
  
  /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)
      252   ctx = context.context()
      253   if ctx.executing_eagerly():
  --&gt; 254     t = convert_to_eager_tensor(value, ctx, dtype)
      255     if shape is None:
      256       return t
  
  /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py in convert_to_eager_tensor(value, ctx, dtype)
      113     return t
      114   else:
  --&gt; 115     return ops.EagerTensor(value, handle, device, dtype)
      116 
      117 
  
  ValueError: could not convert string to float: 'horse'
  </code></pre>