我正在尝试使用PyBrain进行一些简单的神经网络训练。但我不知道如何从文件中加载训练数据。网站上没有任何解释。我不关心格式,因为现在我可以构建它,但我需要将其保存到文件中,而不是手动逐行添加,因为我会有数百行。
我正在尝试使用PyBrain进行一些简单的神经网络训练。但我不知道如何从文件中加载训练数据。网站上没有任何解释。我不关心格式,因为现在我可以构建它,但我需要将其保存到文件中,而不是手动逐行添加,因为我会有数百行。
import pandas as pd
dataset = SupervisedDataSet(6,3)
df = pd.read_csv('mycsvfile.csv')
dataset.setField('input', df.values[:,:6]) # this sets the features
y=[[x] for x in df.values[:,:6])] # Do this to avoid IndexError: tuple index out of range
# as the target field should be a list of lists,
# even if its shape is 1
dataset.setField('target', y) # this set the target[s] field[s]
del df,y