【发布时间】:2020-06-04 17:38:02
【问题描述】:
我有一个 INDArray 的数据,它是 x 的返回值,如下所示:
private static INDArray createDataSet(String path)throws Exception {
List<String> lines = IOUtils.readLines(new FileInputStream(path), StandardCharsets.UTF_8);
double[] position = new double[lines.size()];
double[] year = new double[lines.size()];
double[] month = new double[lines.size()];
double[] day = new double[lines.size()];
double[] close = new double[lines.size()];
int linecount = 0;
Iterator<String> it = lines.iterator();
while(it.hasNext()) {
String line = it.next();
String[] parts = line.split(",");
position[linecount] = linecount;
year[linecount] = Double.valueOf(parts[0]);
month[linecount] = Double.valueOf(parts[1]);
day[linecount] = Double.valueOf(parts[2]);
close[linecount] = Double.valueOf(parts[5]);
linecount++;
}//endloop
double[][] arr2D = new double[][] {position, year, month, day, close};
INDArray x = Nd4j.createFromArray(arr2D);
return x;
}
我正在尝试复制 csvplotter 示例并使用单个输入/输出网络执行线性回归。
如何将数组 row(0) 加载为特征,将数组 row(4) 加载为标签?
更多信息:
System.out.println(ds.rank());
long[] l = ds.shape();
System.out.println(l[0] + " , " + l[1] + " - " + l.length);
System.out.println(ds.length());
结果:
2,
5, 1260 -2
6300
这是我的问题,只是为了清楚:
for (int i = 0; i < nEpochs; i++) {
net.fit(d);
}
根据我尝试添加数据的方式会导致各种错误
【问题讨论】: