本文整理汇总了Java中org.jblas.DoubleMatrix.ones方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix.ones方法的具体用法?Java DoubleMatrix.ones怎么用?Java DoubleMatrix.ones使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jblas.DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.ones方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAddToArray
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
* Test of addToArray method, of class Util.
*/
@Test
public void testAddToArray() {
System.out.println("addToArray");
DoubleMatrix[] a = new DoubleMatrix[2];
a[0] = new DoubleMatrix(1,1,0);
a[1] = new DoubleMatrix(1,1,2);
DoubleMatrix item = DoubleMatrix.ones(1);
DoubleMatrix[] expResult = new DoubleMatrix[3];
expResult[0] = new DoubleMatrix(1,1,0);
expResult[1] = new DoubleMatrix(1,1,1);
expResult[2] = new DoubleMatrix(1,1,2);
DoubleMatrix[] result = Util.addToArray(a, 1, item);
assertArrayEquals(expResult, result);
}
示例2: sigmoid
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
* Element-wise sigmoid
* @param x DoubleMatrix x
* @return DoubleMatrix
*/
protected static DoubleMatrix sigmoid(DoubleMatrix x) {
if (x != null) {
DoubleMatrix ones = DoubleMatrix.ones(x.rows, x.columns);
return ones.div(ones.add(MatrixFunctions.exp(x.neg())));
}
return null;
}
示例3: sigmoidDerivate
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
* Element-wise derivated sigmoid
* @param x DoubleMatrix
* @return DoubleMatrix sigmoid'()
*/
protected static DoubleMatrix sigmoidDerivate(DoubleMatrix x) {
if (x != null) {
DoubleMatrix ones = DoubleMatrix.ones(x.rows, x.columns);
return x.mul(ones.sub(x));
}
return null;
}
示例4: tanhDerivate
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
protected static DoubleMatrix tanhDerivate(DoubleMatrix x) {
if (x != null) {
DoubleMatrix ones = DoubleMatrix.ones(x.rows, x.columns);
return ones.sub(x.mul(x));
}
return null;
}
示例5: testClone_cloneGetsSameValues
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
@Test
public void testClone_cloneGetsSameValues() throws CloneNotSupportedException {
NeuralNetwork clone = (NeuralNetwork) network.clone();
assertFalse(network == clone);
assertTrue(network.getClass() == clone.getClass());
assertTrue(clone.getWeights() == network.getWeights());
DoubleMatrix[] x = new DoubleMatrix[2];
x[0] = DoubleMatrix.ones(2);
x[1] = DoubleMatrix.zeros(2);
network.setWeights(x);
assertFalse(clone.getWeights() == network.getWeights());
clone.setWeights(x);
assertTrue(clone.getWeights() == network.getWeights());
assertTrue(clone.getLayers() == network.getLayers());
}
示例6: testAdd
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
* Test of add method, of class ReplayMemory.
*/
@Test
public void testAdd() {
System.out.println("add method test");
DoubleMatrix state = DoubleMatrix.zeros(1);
int action = 0;
int reward = 0;
DoubleMatrix nextState = DoubleMatrix.ones(1);
ReplayMemory instance = new ReplayMemory(2);
assertEquals(instance.getSize(), 0);
instance.add(state, action, reward, nextState);
assertEquals(instance.getSize(), 1);
instance.add(state, action, reward, nextState);
assertEquals(instance.getSize(), 2);
instance.add(state, action, reward, nextState);
assertEquals(instance.getSize(), 2);
DoubleMatrix state2 = DoubleMatrix.ones(1);
int action2 = 1;
int reward2 = 1;
DoubleMatrix nextState2 = DoubleMatrix.zeros(1);
instance.add(state2, action2, reward2, nextState2);
assertEquals(instance.getSize(), 2);
instance.add(state2, action2, reward2, nextState2);
assertEquals(instance.getSize(), 2);
assertEquals(1, instance.getRandom().getAction());
}
示例7: testGetNextState
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
/**
* Test of getNextState method, of class Replay.
*/
@Test
public void testGetNextState() {
System.out.println("getNextState");
DoubleMatrix expResult = DoubleMatrix.ones(1);
DoubleMatrix result = instance.getNextState();
assertEquals(expResult, result);
}
示例8: BeforeTestMethod
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
@Before
public void BeforeTestMethod() {
instance = new Replay(DoubleMatrix.zeros(1), 2, 1, DoubleMatrix.ones(1));
}