Line | |
---|
1 | package geniusweb.blingbling.Ranknet;
|
---|
2 |
|
---|
3 | import org.nd4j.linalg.api.ndarray.INDArray;
|
---|
4 | import org.nd4j.linalg.factory.Nd4j;
|
---|
5 | import org.nd4j.linalg.ops.transforms.Transforms;
|
---|
6 |
|
---|
7 | public class SigmoidActivationFunction implements IActivationFunction {
|
---|
8 | public static final IActivationFunction INSTANCE = new SigmoidActivationFunction();
|
---|
9 |
|
---|
10 | public INDArray output(INDArray input) {
|
---|
11 | return Transforms.sigmoid(input);
|
---|
12 | }
|
---|
13 |
|
---|
14 | public INDArray derivative(INDArray input) {
|
---|
15 | INDArray sigmoid = Transforms.sigmoid(input);
|
---|
16 | INDArray ones = Nd4j.ones(sigmoid.shape());
|
---|
17 |
|
---|
18 | return sigmoid.mul(ones.sub(sigmoid));
|
---|
19 | }
|
---|
20 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.