【发布时间】:2021-11-17 16:23:15
【问题描述】:
目前,我有 一个 数组用于我的深度学习网络:“光标到目标的距离”。看起来像这样:
数据:
//Array of last 20 hits that occurred....0.2254129882770741,0.16240028500697098,0.1375113264805262,0.35381412903306814,0.2397808577758728,0.29521410375781615,0.433078049523479,0.18128063688236676,0.28972880920545074,.......,0
0.21006877393551196,0.1987825902438688,0.165062866168541,0.21124451464164626,0.29661243231132695,0.1999213305507936,0.21662535204339559,0.346436898477125,0.16091104172813975,......,0
... etc
然后我使用这个单一的数组来创建一个非常通用的模型:
//Note: VERY generic machine-learning code. Practically the iris example except modified for different values
RecordReader recordReader = new CSVRecordReader(numLinesToSkip, delimiter);
recordReader.initialize(new FileSplit(new File("killauraData1.txt")));
// objects, ready for use in neural network
int labelIndex = 20;
int numClasses = 2;
int batchSize = 40;them into one
DataSetIterator iterator = new RecordReaderDataSetIterator(recordReader, batchSize, labelIndex, numClasses);
DataSet allData = iterator.next();
allData.shuffle();
// int usePercentToTrain = 65;//Use this percent
SplitTestAndTrain testAndTrain = allData.splitTestAndTrain(0.4);
DataSet trainingData = testAndTrain.getTrain();
DataSet testData = testAndTrain.getTest();
// We need to normalize our data. We'll use NormalizeStandardize (which gives us
// mean 0, unit variance):
// DataNormalization normalizer = new NormalizerStandardize();
// normalizer.fit(trainingData); //Collect the statistics (mean/stdev) from the
// training data. This does not modify the input data
// normalizer.transform(trainingData); //Apply normalization to the training
// data
// normalizer.transform(testData); //Apply normalization to the test data. This
// is using statistics calculated from the *training* set
final int numInputs = 20;
int outputNum = 2;
long seed = 6;
log("Build model....");
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(seed).activation(Activation.TANH)
.weightInit(WeightInit.XAVIER).updater(new Sgd(0.1)).l2(1e-4).list()
.layer(0, new DenseLayer.Builder().nIn(numInputs).nOut(outputNum).build())
.layer(1, new DenseLayer.Builder().nIn(2).nOut(2).build())
.layer(2,
new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
.activation(Activation.SOFTMAX) // Override the global TANH activation with softmax for
// this layer
.nIn(2).nOut(outputNum).build())
.build();
// run the model
model = new MultiLayerNetwork(conf);
model.init();
// record score once every 100 iterations
model.setListeners(new ScoreIterationListener(200));
for (int i = 0; i < 5000; i++) {
model.fit(trainingData);
}
但我想使用多个参数。例如,“光标与目标的距离”、“玩家最近的速度”、“命中精度”等。所有这些都是double[],列出多达 20 种不同的命中准确率、光标距离等。
我将如何使用这些多个不同的数组而不是一个数组来训练我的模型?
【问题讨论】:
标签: java machine-learning deeplearning4j