需要将DatasetV1Adapter设为用于NN训练的数据集

时间:2019-04-24 14:35:20

标签: python tensorflow

尝试将csv加载到数据集以训练NN

# load a csv
CSV_PATH = './dataset.csv'
dataset = tf.data.experimental.make_csv_dataset(CSV_PATH, batch_size)

#Initializing the variables
init = tf.global_variables_initializer()
#Create a session
with tf.Session() as sess:
    sess.run(init)
    #Training epoch
    for epoch in range(number_epochs):
        #Get one batch of images
        batch_x, batch_y = dataset.train.next_batch(batch_size)
        #Run the optimizer feeding the network with the batch
        sess.run(optimizer, feed_dict={X: batch_x, Y: batch_y})
        #Display the epoch (just every 100)
        if epoch % 100 == 0:
            print("Epoch:", '%d' % (epoch))

执行时出现以下错误

回溯(最近通话最近):   文件“ c:/Users/afickbohm/Desktop/pyfiles/IDM/metis.py”,第63行,在     batch_x,batch_y =数据集.train.next_batch(批量大小) AttributeError:“ DatasetV1Adapter”对象没有属性“ train”

因此,数据集不是数据集类型。我该怎么做?

0 个答案:

没有答案