Tensorflow';numpy.ndarray和#x27;对象没有属性';列车';

Tensorflow';numpy.ndarray和#x27;对象没有属性';列车';,numpy,tensorflow,Numpy,Tensorflow,我也遇到同样的问题,那就是: 属性错误回溯(最近一次调用最后一次)在()1中,用于 范围(1000):--->2批次X,批次Y=data.train.next批次(100)3 sess.run(train_step,feed_dict={x:batch_xs,y_u:batch_ys}) AttributeError:'numpy.ndarray'对象没有属性'train' 你如何解决这个问题 from __future__ import print_function import matplo

我也遇到同样的问题,那就是:

属性错误回溯(最近一次调用最后一次)在()1中,用于 范围(1000):--->2批次X,批次Y=data.train.next批次(100)3 sess.run(train_step,feed_dict={x:batch_xs,y_u:batch_ys})

AttributeError:'numpy.ndarray'对象没有属性'train'

你如何解决这个问题

from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import matplotlib

# Import MNIST data
#from tensorflow.examples.tutorials.mnist import input_data
#mnistt = input_data.read_data_sets("/tttmp/data/", one_hot=True)

from numpy import genfromtxt

import csv
import tensorflow as tf
%matplotlib inline

# Read data...
x_input = genfromtxt('Data_Coffee.csv',delimiter=',')
y_input = genfromtxt('Class_Coffee.csv',delimiter=',')

data=genfromtxt('Data_Coffee.csv',delimiter=',')

matSize = np.shape(data)

# Parameters
learning_rate = 0.001
training_epochs = 15
batch_size = 100
display_step = 1


# tf Graph input
x = tf.placeholder(tf.float32, [None, matSize[0]])
y = tf.placeholder(tf.float32, [None, matSize[1]])

#x= genfromtxt('Data_Coffee.csv',delimiter=',')
#y= genfromtxt('Class_Coffee.csv',delimiter=',')


# Initializing the variables
init = tf.global_variables_initializer()

# Launch the graph
with tf.Session() as sess:
    sess.run(init)

    # Training cycle
    for epoch in range(training_epochs):
        avg_cost = 0.
        total_batch = int(x.train.num_examples/batch_size)

        # Loop over all batches
        for i in range(total_batch):
            batch_x, batch_y = data.train.next_batch(batch_size)
            # Run optimization op (backprop) and cost op (to get loss value)
            _, c = sess.run([optimizer, cost], feed_dict={x: batch_x, y: batch_y})
            # Compute average loss
            avg_cost += c / total_batch
        # Display logs per epoch step
        if epoch % display_step == 0:
            print("Epoch:", '%04d' % (epoch+1), "cost=", \
                "{:.9f}".format(avg_cost))
    print("Optimization Finished!")

我认为您是从MNIST示例中复制了此模式:data.train.next\u batch


在MNIST示例中,数据是作为具有train变量的类的对象读取的,而您只是作为NumPy数组读取数据。

此处
x\u input
只是一个NumPy数组。您需要编写自己的列车数据,或等待您的回复。你能详细说明一下吗?有没有后续的例子和链接?我想我需要向tensorflow提供数据,但我不知道如何做错误日志引用错误日志是:AttributeError:'numpy.ndarray'对象没有属性'train'难道从numpy数组创建tensorflow对象(使用
train
方法)不是tensorflow文档或教程的基本部分吗?如果你在设置这个问题上已经走了这么远,你肯定已经遇到了如何创建这样一个对象的说明。是的,我是。原始来自MNIST示例:MNIST.train.next\U批次。如何编辑我的数据?