【问题标题】:Split image array and labels dataframe into train, test and validataion sets将图像数组和标签数据帧拆分为训练、测试和验证集
【发布时间】:2021-11-12 07:13:43
【问题描述】:

我有一个形状为 (30000, 128,128,3) 的图像数组(从 npy 文件加载)和一个形状为 (30000, 1) 的标签数据框。如何将它们拆分为训练集、测试集和验证集,以便继续构建 CNN 模型?

【问题讨论】:

    标签: keras computer-vision conv-neural-network tensor


    【解决方案1】:

    您可以使用包 sklearn。如果您的 imagew 数组为“X”且标签为“Y”,请使用:

    >> from sklearn.model_selection import train_test_split
    

    这个包在训练、测试和验证中拆分日期集:

    >> X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=33)
    

    参考:https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html

    编码愉快!!

    【讨论】:

      猜你喜欢
      • 2018-11-19
      • 2019-05-01
      • 2018-06-04
      • 1970-01-01
      • 2021-01-19
      • 2019-12-15
      • 2021-05-08
      • 1970-01-01
      • 2016-07-04
      相关资源
      最近更新 更多