title: keras - Failed to convert a NumPy array to a Tensor (Unsupported object type int)
body: <p>I am trying to use neural network on a classification problem.
  The dataset has columns with numerical and categorical data.
  I am trying to use column transformer to prepare the data for fitting a model.
  There are steps in Column Transformer to deal with individual rows depending on the data type.</p>
  <p>Column Transformer only accepts pd.DataFrame input and Keras model needs an np.array input. So after transforming the columns I am trying to cast the data  in to an array.</p>
  <p>Of course i looked up other similar threads and tried the various suggestions. I also tried to fit the column transformer without passing it through the NN, and checked the data type and dimensions. It is working fine. But somehow Keras can't accept the array. I get the same error each time:</p>
  <p>Value Error: Failed to convert a NumPy array to a Tensor (Unsupported object type int).</p>
  <p>Does anyone now how to fix this ?</p>
  <pre><code>##### evaluate model with standardized dataset
  epochs = 20
  
  nn_1 = KerasClassifier(build_fn=create_baseline, epochs=epochs, batch_size=10, validation_data=(X_val, y_val), callbacks=[history])
  
  ##### define column transformer
  col_trans = ColumnTransformer(remainder='passthrough',transformers=[('cat1',Pipeline(steps=[('ohe',OneHotEncoder(handle_unknown='ignore'))]),
                                                    ['hotel', 'meal',
                                                     'market_segment',
                                                     'distribution_channel',
                                                     'deposit_type',
                                                     'customer_type',
                                                     'country']),
                                                   
  ('cat2',Pipeline(steps=[('oe',
                                                                OrdinalEncoder(handle_unknown='use_encoded_value',
                                                                                  unknown_value=-999))]),
                                                    ['reserved_room_type',
                                                     'assigned_room_type']),
                                                   ('cont_scale',
                                               
  Pipeline(steps=[('scaler',
                                                                     StandardScaler())]),
                                                    ['lead_time', 'total_stay',
                                                    'adr','total_people'])])
  
  # fit column transformer
  col_trans.fit(X_train)
  
  data = col_trans.transform(X_train)
  
  # convert to arrays 
  
  X_train = csr_matrix(data, dtype=np.float32).toarray()
  
  y_train = np.asarray(y_train).astype(np.float32)
  
  model_nn_1 = Pipeline(
      steps=[(&quot;NN&quot;, nn_1)]
  )
  
  ##### fit the NN model on the training set
  
  model_nn_1.fit(X_train,y_train)
  </code></pre>
  <p>'''</p>
  <p>The error:</p>
  <pre><code>Epoch 1/20
  6533/6533 [==============================] - ETA: 0s - loss: 0.4469 - accuracy: 0.8001 - precision: 0.7836 - recall: 0.6378 - mse: 0.1370 - rmse: 0.3701
  ---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-123-41ba9692bd66&gt; in &lt;module&gt;()
       39 # fit the NN model on the training set
       40 
  ---&gt; 41 model_nn_1.fit(X_train,y_train)
       42 
       43 # evaluate the keras model
  
  4 frames
  /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/constant_op.py in convert_to_eager_tensor(value, ctx, dtype)
      100       dtype = dtypes.as_dtype(dtype).as_datatype_enum
      101   ctx.ensure_initialized()
  --&gt; 102   return ops.EagerTensor(value, ctx.device_name, dtype)
      103 
      104 
  
  ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int).
  </code></pre>