小编Mar*_*ugo的帖子

使用Google的TensorFlow添加额外的隐藏图层

我正在尝试使用TensorFlow创建一个多标签分类器.虽然我在添加和连接隐藏图层时遇到了麻烦.

我正在学习本教程:http://jrmeyer.github.io/tutorial/2016/02/01/TensorFlow-Tutorial.html

我正在使用的数据是UCI的Iris数据,编码为one-hot:

训练X [105,4]

5,3.2,1.2,0.2
5.5,3.5,1.3,0.2
4.9,3.1,1.5,0.1
4.4,3,1.3,0.2
5.1,3.4,1.5,0.2
.
.
.
Run Code Online (Sandbox Code Playgroud)

训练Y [105,3]

0,0,1
0,0,1
0,0,1
0,0,1
0,0,1
0,0,1
.
.
.
Run Code Online (Sandbox Code Playgroud)

我也在使用分别为[45,4]和[45,3]的测试数据X和Y.

这是我的python代码:

import tensorflow as tf
import numpy as np
import tarfile
import os
import matplotlib.pyplot as plt
import time

## Import data
def csv_to_numpy_array(filePath, delimiter):
    return np.genfromtxt(filePath, delimiter=delimiter, dtype=None)

trainX = csv_to_numpy_array("Iris_training_x.csv", delimiter=",").astype(np.float32)
trainY = csv_to_numpy_array("Iris_training_y.csv", delimiter=",").astype(np.float32)
testX = csv_to_numpy_array("Iris_testing_x.csv", delimiter=",").astype(np.float32)
testY = csv_to_numpy_array("Iris_testing_y.csv", delimiter=",").astype(np.float32)


# Data Set Paramaters
numFeatures = trainX.shape[1] …
Run Code Online (Sandbox Code Playgroud)

python machine-learning neural-network tensorflow

8
推荐指数
1
解决办法
5346
查看次数