相关疑难解决方法(0)

Tensorflow无效参数:断言失败[标签ID必须<n_classes]

我在使用Python 2.7在Tensorflow 1.3.0中实现DNNClassifier时遇到错误.我从Tensorflow tf.estimator Quickstart教程中获取了示例代码,我想用自己的数据集运行它:3D坐标和10个不同的类(int标签).这是我的实现:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

def ReadLabels(file):
    #load the labels from test file here
    labelFile = open(file, "r")
    Label = labelFile.readlines();
    returnL = [[Label[i][j+1] for j in range(len(Label[0])-3)] for i in range(len(Label))]
    returnLint = list();
    for i in range(len(returnL)):
        tmp = ''
        for j in range(len(returnL[0])):
            tmp += str(returnL[i][j])
        returnLint.append(int(tmp))
    return returnL, returnLint

def NumpyReadBin(file,numcols,type):
    #load the data from binary file here
    import numpy as np
    trainData = np.fromfile(file,dtype=type)
    numrows = len(trainData)/numcols …
Run Code Online (Sandbox Code Playgroud)

python tensorflow

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

标签 统计

python ×1

tensorflow ×1