本文整理匯總了Java中org.nd4j.linalg.factory.Nd4j.hstack方法的典型用法代碼示例。如果您正苦於以下問題:Java Nd4j.hstack方法的具體用法?Java Nd4j.hstack怎麽用?Java Nd4j.hstack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.nd4j.linalg.factory.Nd4j
的用法示例。
在下文中一共展示了Nd4j.hstack方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTrainingData
import org.nd4j.linalg.factory.Nd4j; //導入方法依賴的package包/類
@Override
public FederatedDataSet getTrainingData() {
Random rand = new Random(seed);
double[] sum = new double[N_SAMPLES];
double[] input1 = new double[N_SAMPLES];
double[] input2 = new double[N_SAMPLES];
for (int i = 0; i < N_SAMPLES; i++) {
input1[i] = MIN_RANGE + (MAX_RANGE - MIN_RANGE) * rand.nextDouble();
input2[i] = MIN_RANGE + (MAX_RANGE - MIN_RANGE) * rand.nextDouble();
sum[i] = input1[i] + input2[i];
}
INDArray inputNDArray1 = Nd4j.create(input1, new int[]{N_SAMPLES, 1});
INDArray inputNDArray2 = Nd4j.create(input2, new int[]{N_SAMPLES, 1});
INDArray inputNDArray = Nd4j.hstack(inputNDArray1, inputNDArray2);
INDArray outPut = Nd4j.create(sum, new int[]{N_SAMPLES, 1});
DataSet dataSet = new DataSet(inputNDArray, outPut);
dataSet.shuffle();
return new FederatedDataSetImpl(dataSet);
}
示例2: getTestData
import org.nd4j.linalg.factory.Nd4j; //導入方法依賴的package包/類
@Override
public FederatedDataSet getTestData() {
Random rand = new Random(seed);
int numSamples = N_SAMPLES/10;
double[] sum = new double[numSamples];
double[] input1 = new double[numSamples];
double[] input2 = new double[numSamples];
for (int i = 0; i < numSamples; i++) {
input1[i] = MIN_RANGE + (MAX_RANGE - MIN_RANGE) * rand.nextDouble();
input2[i] = MIN_RANGE + (MAX_RANGE - MIN_RANGE) * rand.nextDouble();
sum[i] = input1[i] + input2[i];
}
INDArray inputNDArray1 = Nd4j.create(input1, new int[]{numSamples, 1});
INDArray inputNDArray2 = Nd4j.create(input2, new int[]{numSamples, 1});
INDArray inputNDArray = Nd4j.hstack(inputNDArray1, inputNDArray2);
INDArray outPut = Nd4j.create(sum, new int[]{numSamples, 1});
return new FederatedDataSetImpl(new DataSet(inputNDArray, outPut));
}
示例3: getTrainingData
import org.nd4j.linalg.factory.Nd4j; //導入方法依賴的package包/類
private static DataSetIterator getTrainingData(int batchSize, Random rand){
double [] sum = new double[nSamples];
double [] input1 = new double[nSamples];
double [] input2 = new double[nSamples];
for (int i= 0; i< nSamples; i++) {
int MIN_RANGE = 0;
int MAX_RANGE = 3;
input1[i] = MIN_RANGE + (MAX_RANGE - MIN_RANGE) * rand.nextDouble();
input2[i] = MIN_RANGE + (MAX_RANGE - MIN_RANGE) * rand.nextDouble();
sum[i] = input1[i] + input2[i];
}
INDArray inputNDArray1 = Nd4j.create(input1, new int[]{nSamples,1});
INDArray inputNDArray2 = Nd4j.create(input2, new int[]{nSamples,1});
INDArray inputNDArray = Nd4j.hstack(inputNDArray1,inputNDArray2);
INDArray outPut = Nd4j.create(sum, new int[]{nSamples, 1});
DataSet dataSet = new DataSet(inputNDArray, outPut);
List<DataSet> listDs = dataSet.asList();
Collections.shuffle(listDs,rng);
return new ListDataSetIterator(listDs,batchSize);
}