当前位置: 首页>>代码示例>>Java>>正文


Java Transforms.sigmoid方法代码示例

本文整理汇总了Java中org.nd4j.linalg.ops.transforms.Transforms.sigmoid方法的典型用法代码示例。如果您正苦于以下问题:Java Transforms.sigmoid方法的具体用法?Java Transforms.sigmoid怎么用?Java Transforms.sigmoid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.nd4j.linalg.ops.transforms.Transforms的用法示例。


在下文中一共展示了Transforms.sigmoid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSigmoid

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Test
public void testSigmoid() {
    INDArray n = Nd4j.create(new float[]{1, 2, 3, 4});
    INDArray assertion = Nd4j.create(new float[]{0.73105858f, 0.88079708f, 0.95257413f, 0.98201379f});
    INDArray sigmoid = Transforms.sigmoid(n);
    assertEquals(assertion,sigmoid);
}
 
开发者ID:wlin12,项目名称:JNN,代码行数:8,代码来源:NDArrayTests.java

示例2: testSum

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Test
public void testSum() {
    SameDiff sameDiff = SameDiff.create();
    INDArray arr = Transforms.sigmoid(Nd4j.linspace(1, 4, 4));
    SDVariable x = sameDiff.var("x", arr);
    SDVariable result = sameDiff.sum(x, 1); //[1,4].sum(1) == [1,1]
    assertArrayEquals(new int[]{1,1}, result.getShape());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:9,代码来源:SameDiffTests.java

示例3: testTranspose

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Test
public void testTranspose() {
    SameDiff sameDiff = SameDiff.create();
    INDArray arr = Transforms.sigmoid(Nd4j.linspace(1, 4, 4));
    SDVariable x = sameDiff.var("x", arr);
    SDVariable result = sameDiff.transpose(x);
    sameDiff.exec();
    assertArrayEquals(new int[]{4, 1}, result.getArr().shape());

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:11,代码来源:SameDiffTests.java

示例4: testEval

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Test
public void testEval() {
    SameDiff sameDiff = SameDiff.create();
    INDArray arr = Nd4j.linspace(1, 4, 4);
    SDVariable x = sameDiff.var("x", arr);
    SDVariable sigmoid = sameDiff.sigmoid(x);
    INDArray assertion = Transforms.sigmoid(arr);
    INDArray[] eval = sameDiff.eval(Collections.singletonMap("x", arr));
    assertEquals(assertion, eval[0]);

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:12,代码来源:SameDiffTests.java

示例5: testDenseLayerForwardPass

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Test
public void testDenseLayerForwardPass() {
    Nd4j.getRandom().setSeed(12345);

    SameDiff sd = SameDiff.create();

    INDArray iInput = Nd4j.rand(3,4);
    INDArray iWeights = Nd4j.rand(4,5);
    INDArray iBias = Nd4j.rand(1,5);

    SDVariable input = sd.var("input", iInput);
    SDVariable weights = sd.var("weights", iWeights);
    SDVariable bias = sd.var("bias", iBias);

    SDVariable mmul = sd.mmul("mmul", input, weights);
    SDVariable z = mmul.add("z", bias);
    SDVariable out = sd.sigmoid("out", z);

    INDArray expMmul = iInput.mmul(iWeights);
    INDArray expZ = expMmul.addRowVector(iBias);
    INDArray expOut = Transforms.sigmoid(expZ, true);

    sd.exec();

    assertEquals(expMmul, mmul.getArr());
    assertEquals(expZ, z.getArr());
    assertEquals(expOut, out.getArr());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:29,代码来源:SameDiffTests.java

示例6: testSigmoid

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Test
public void testSigmoid() {
    INDArray n = Nd4j.create(new float[] {1, 2, 3, 4});
    INDArray assertion = Nd4j.create(new float[] {0.73105858f, 0.88079708f, 0.95257413f, 0.98201379f});
    INDArray sigmoid = Transforms.sigmoid(n, false);
    assertEquals(assertion, sigmoid);
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:8,代码来源:Nd4jTestsC.java

示例7: testSigmoid

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Test
public void testSigmoid() {
    INDArray n = Nd4j.create(new float[] {1, 2, 3, 4});
    INDArray assertion = Nd4j.create(new float[] {0.73105858f, 0.88079708f, 0.95257413f, 0.98201379f});
    INDArray sigmoid = Transforms.sigmoid(n, false);
    assertEquals(getFailureMessage(), assertion, sigmoid);

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:9,代码来源:NDArrayTestsFortran.java

示例8: runOp

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Override
public void runOp() {
    Transforms.sigmoid(arr);
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:5,代码来源:TransformOpRunner.java

示例9: runOp

import org.nd4j.linalg.ops.transforms.Transforms; //导入方法依赖的package包/类
@Override
public void runOp() {
    Transforms.sigmoid(arr, false);
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:5,代码来源:TransformOpRunner.java


注:本文中的org.nd4j.linalg.ops.transforms.Transforms.sigmoid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。