【问题标题】:split dataset into train and test using tensorflow使用 tensorflow 将数据集拆分为训练和测试
【发布时间】:2021-02-27 01:39:28
【问题描述】:

我想将我的完整数据集(每个原始数据都有多个特征)拆分为训练集和测试集。除了使用 scikit-learn 的 train-test-split 之外,还有其他合适的方法来拆分我的数据吗?以及拆分时我需要洗牌我的数据。 (如果建议的方法是基于tensorflow的,那就太好了。)

【问题讨论】:

    标签: tensorflow machine-learning train-test-split


    【解决方案1】:

    试试这个代码:

    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:]
    

    【讨论】: