本文整理匯總了Java中org.apache.commons.math3.linear.MatrixUtils.createFieldVector方法的典型用法代碼示例。如果您正苦於以下問題:Java MatrixUtils.createFieldVector方法的具體用法?Java MatrixUtils.createFieldVector怎麽用?Java MatrixUtils.createFieldVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.linear.MatrixUtils
的用法示例。
在下文中一共展示了MatrixUtils.createFieldVector方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calcWeightDeltaTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
@Test
public void calcWeightDeltaTest() {
double eta = 0.1;
Complex[] d = {new Complex(0.1),new Complex(0.2)};
Complex[] in = {new Complex(0.1),new Complex(0.2), new Complex(0.3)};
FieldVector<Complex> delta = MatrixUtils.createFieldVector(d);
FieldVector<Complex> input = MatrixUtils.createFieldVector(in);
FieldMatrix<Complex> weightDiff = this.calcWeightDelta(delta,input,eta);
assertEquals(2,weightDiff.getRowDimension());
assertEquals(3,weightDiff.getColumnDimension());
assertEquals(0.001,weightDiff.getEntry(0,0).getReal(),0.00001);
assertEquals(0.002,weightDiff.getEntry(0,1).getReal(),0.00001);
assertEquals(0.003,weightDiff.getEntry(0,2).getReal(),0.00001);
assertEquals(0.002,weightDiff.getEntry(1,0).getReal(),0.00001);
assertEquals(0.004,weightDiff.getEntry(1,1).getReal(),0.00001);
assertEquals(0.006, weightDiff.getEntry(1, 2).getReal(), 0.00001);
}
示例2: layerpropagateTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
@Test
public void layerpropagateTest() throws Exception {
FeedForwardNet net = getNetWith1Weights();
SingleThreadPropagation prop = new SingleThreadPropagationTest();
prop.setNetWork(net);
prop.setEta(10);
SingleThreadCalculation calc = new SingleThreadCalculation(net);
Complex[] in = {new Complex(1),new Complex(1)};
Complex[] tar = {new Complex(1)};
FieldVector<Complex> input = MatrixUtils.createFieldVector(in);
FieldVector<Complex> target = MatrixUtils.createFieldVector(tar);
FieldVector<Complex> output = calc.calculate(input);
FieldVector<Complex> error = target.subtract(output);
prop.propagate(error, calc.getLayerResults());
assertEquals(1.161527544, net.getLayers().get(1).getNeurons().get(0).getOutputs().get(0).getWeight().getReal(), 0.00001);
assertEquals(1.01925455, net.getLayers().get(0).getNeurons().get(0).getOutputs().get(0).getWeight().getReal(), 0.00001);
}
示例3: transform
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
public static FieldVector transform(double[] vector){
Complex[] ret = new Complex[vector.length];
for(int i = 0; i < ret.length; i++) {
ret[i] = transform(vector[i]);
}
return MatrixUtils.createFieldVector(ret);
}
示例4: calculationTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
@Test
public void calculationTest() throws SeviException {
FeedForwardNet net = new FeedForwardNet();
net.addLayer(2, ActivationFunction.Sigmoid);
net.addLayer(2, ActivationFunction.Sigmoid);
net.addLayer(1, ActivationFunction.Sigmoid);
Neuron outputn = net.getLayers().get(2).getNeurons().get(0);
outputn.getInputs().get(0).setWeight(new Complex(0.5));
outputn.getInputs().get(1).setWeight(new Complex(0.7));
Neuron input1 = net.getLayers().get(0).getNeurons().get(0);
input1.getOutputs().get(0).setWeight(new Complex(1));
input1.getOutputs().get(1).setWeight(new Complex(0.9));
Neuron input2 = net.getLayers().get(0).getNeurons().get(1);
input2.getOutputs().get(0).setWeight(new Complex(0.1));
input2.getOutputs().get(1).setWeight(new Complex(0.2));
Complex[] input = {new Complex(1), new Complex(2)};
FieldVector<Complex> in = MatrixUtils.createFieldVector(input);
SingleThreadCalculation calc = new SingleThreadCalculation(net);
FieldVector<Complex> out = calc.calculate(in);
assertEquals(0.7685247, calc.getLayerResults().get(0).getOutput().getEntry(0).getReal(),0.00001);
assertEquals(0.7858349, calc.getLayerResults().get(0).getOutput().getEntry(1).getReal(),0.00001);
assertEquals(0.717956, out.getEntry(0).getReal(),0.00001);
}
示例5: calcDeltaTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
@Test
public void calcDeltaTest() {
Complex[] err = {new Complex(1), new Complex(2)};
Complex[] out = {new Complex(3), new Complex(4)};
Complex[] sh = {new Complex(-6), new Complex(-24)};
FieldVector<Complex> error = MatrixUtils.createFieldVector(err);
FieldVector<Complex> output = MatrixUtils.createFieldVector(out);
FieldVector<Complex> should = MatrixUtils.createFieldVector(sh);
FieldVector<Complex> result = this.calcDelta(error, output);
System.out.println(should.equals(result));
assertEquals(should,result);
}
示例6: calcErrorTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
@Test
public void calcErrorTest() {
Complex[][] weights = {{new Complex(1), new Complex(2)},{new Complex(1), new Complex(2)}};
Complex[] delta = {new Complex(1), new Complex(2)};
Complex[] should = {new Complex(3), new Complex(6)};
FieldMatrix<Complex> w = MatrixUtils.createFieldMatrix(weights);
FieldVector<Complex> d = MatrixUtils.createFieldVector(delta);
FieldVector<Complex> s = MatrixUtils.createFieldVector(should);
assertEquals(s,this.calcError(w,d));
}
示例7: getInputMatrixTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
@Test
public void getInputMatrixTest() throws SeviException{
Complex[] in = {new Complex(1)}, out = {new Complex(2)};
ComplexPair c = new ComplexPair(MatrixUtils.createFieldVector(in),MatrixUtils.createFieldVector(out));
ComplexDataset cd = new ComplexDataset();
cd.add(c);
Complex[][] matrix = cd.getInputMatrix();
assertEquals(1,matrix.length);
assertEquals(1,matrix[0].length);
assertEquals(1,matrix[0][0].getReal(),0.0001);
}
示例8: getOutputMatrixTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
@Test
public void getOutputMatrixTest() throws SeviException{
Complex[] in = {new Complex(1)}, out = {new Complex(2)};
ComplexPair c = new ComplexPair(MatrixUtils.createFieldVector(in),MatrixUtils.createFieldVector(out));
ComplexDataset cd = new ComplexDataset();
cd.add(c);
Complex[][] matrix = cd.getOutputMatrix();
assertEquals(1,matrix.length);
assertEquals(1,matrix[0].length);
assertEquals(2,matrix[0][0].getReal(),0.0001);
}
示例9: getInitializedVector
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
private FieldVector<Complex> getInitializedVector() {
Complex[] vector = new Complex[2];
vector[0] = new Complex(1);
vector[1] = new Complex(2);
return MatrixUtils.createFieldVector(vector);
}
示例10: getOutTest
import org.apache.commons.math3.linear.MatrixUtils; //導入方法依賴的package包/類
public void getOutTest(){
Complex[][] m = {{new Complex(1),new Complex(2)},{new Complex(3),new Complex(4)}};
FieldMatrix<Complex> matrix = MatrixUtils.createFieldMatrix(m);
Complex[] v = {new Complex(1),new Complex(2)};
FieldVector<Complex> vector = MatrixUtils.createFieldVector(v);
FieldVector<Complex> multi = matrix.operate(vector);
System.out.println("Matrix:");
out(matrix);
System.out.println("Vector:");
out(vector);
System.out.println("Result:");
out(multi);
}