tensorflowmachine-learningtrain-test-split

split dataset into train and test using tensorflow


How can I shuffle and split my full dataset into train and test sets using Tensorflow? I don't want to use scikit-learn's train-test-split.


Solution

  • Try this code:

    import tensorflow as tf
    input = tf.random.uniform([100, 5], 0, 10, dtype=tf.int32)
    input = tf.random.shuffle(input)
    train_ds = input[:90]
    test_ds = input[-10:]