【问题标题】:Tensorflow data processing using UCI Dataset使用 UCI 数据集的 TensorFlow 数据处理
【发布时间】:2018-03-04 07:52:04
【问题描述】:

我正在尝试使用 Tensorflow 来识别 UCI 数据集的手写数字(https://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits)。其中每一行是一个扁平的 8*8 图像像素矩阵,最后一个属性是类代码 0-9。 然而,我遵循的教程是关于 MNIST 数据的,这是完全不同的。它有一个 0-255 值的 28*28 矩阵。所以,它是这样的:

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data", one_hot=True)
x = tf.placeholder('float', [None, 784])
y = tf.placeholder('float')

由于我是 Tensorflow 的新手,我无法为 UCI 数据准备神经网络模型。我只是想要一些关于如何进行的方向。我有 2 个主要问题。

  1. 这是导入数据的正确方法吗?
  2. 如何获取'y'标签作为最后一个属性?

目前我正在考虑做这样的事情:

filename_queue = tf.train.string_input_producer(["optdigits.tra"])
reader = tf.TextLineReader()
_, serialized_example = reader.read(filename_queue)
image,label = decode(serialized_example)
x = tf.placeholder('float', [None, 64])
y = tf.placeholder('float')

基本上,我想准备一个具有 64 个节点的输入层和一个带有输出的 'y' 标签来训练 NN model

【问题讨论】:

    标签: python tensorflow machine-learning neural-network mnist


    【解决方案1】:

    我也是新手,可能这不是一个好方法。 我用numpy导入数据,然后转成tensorflow格式。

    import tensorflow as tf
    import numpy as np
    
    trainingDataSet_ = np.loadtxt('/data/optdigits.tra', delimiter=',');
    trainingDataSet = tf.convert_to_tensor(trainingDataSet_, np.int32)
    
    # store labels of each sample
    y = trainingDataSet[:, 64]
    
    # remove lables from features
    x = trainingDataSet[:, :64]
    

    【讨论】:

      猜你喜欢
      • 2023-03-15
      • 2018-09-03
      • 2021-09-06
      • 1970-01-01
      • 1970-01-01
      • 2019-08-31
      • 1970-01-01
      • 1970-01-01
      • 2019-03-24
      相关资源
      最近更新 更多