title: Want to split train and test data gotten from a csv with tensorflow
body: <p>I wanted to split train and test data of a csv with tensorflow but I didn't find an order like np.loadtxt in tensor and tried to do splits with numpy and convert it to tensor, but I get an error like below:</p>
  
  <pre><code>      TypeError: object of type 'Tensor' has no len()
  </code></pre>
  
  <p>and here is my code:</p>
  
  <pre><code>     import tensorflow as tf
       import numpy as np
       import matplotlib.pyplot as plt
       from sklearn.model_selection import train_test_split
  
       x = tf.convert_to_tensor( np.loadtxt('data.csv', delimiter=','))
       y = tf.convert_to_tensor(np.loadtxt('labels.csv', delimiter=','))
  
       x_train, x_test, y_train, y_test = train_test_split(x, y, 
       test_size=0.25, random_state='')
  
       model = tf.keras.models.Sequential([
       tf.keras.layers.Flatten(input_shape= (426,30,1)),
       tf.keras.layers.Dense(126, activation=tf.nn.tanh),
        #tf.keras.layers.Dropout(0.2),
        tf.keras.layers.Dense(10, activation=tf.nn.tanh)
         ])
  
         model.compile(optimizer='sgd',
            loss='mean_squared_error',
            metrics=['accuracy'])
  
         history = model.fit(x_train, y_train, epochs=5 )  #validation_data 
         = [x_test, y_test])
         model.evaluate(x_test, y_test)
  
        t_predicted = model.predict(x_test)
        out_predicted = np.argmax(t_predicted, axis=1)
        conf_matrix = tf.confusion_matrix(y_test, out_predicted)
        with tf.Session():
         print('Confusion Matrix: \n\n', tf.Tensor.eval(conf_matrix, 
       feed_dict=None, session=None))
  
        # summarize history for accuracy
        plt.plot(history.history['acc'])
        plt.plot(history.history['val_acc'])
        plt.title('model accuracy')
        plt.ylabel('accuracy')
        plt.xlabel('epoch')
        plt.legend(['train', 'test'], loc='upper left')
        plt.show()
  
       # summarize history for loss
       plt.plot(history.history['loss'])
       plt.plot(history.history['val_loss'])
       plt.title('model loss')
       plt.ylabel('loss')
       plt.xlabel('epoch')
       plt.legend(['train', 'test'], loc='upper left')
       plt.show()
  </code></pre>