Search in sources :

Example 1 with SigmoidActivationLayer

use of com.simiacryptus.mindseye.layers.java.SigmoidActivationLayer in project MindsEye by SimiaCryptus.

the class SigmoidTreeNetwork method getHead.

@Nullable
@Override
public synchronized DAGNode getHead() {
    if (null == head) {
        synchronized (this) {
            if (null == head) {
                reset();
                final DAGNode input = getInput(0);
                switch(getMode()) {
                    case Linear:
                        head = add(alpha.setFrozen(false), add(alphaBias.setFrozen(false), input));
                        break;
                    case Fuzzy:
                        {
                            final DAGNode gateNode = add(gate.setFrozen(false), null != gateBias ? add(gateBias.setFrozen(false), input) : input);
                            head = add(new ProductInputsLayer(), add(alpha.setFrozen(false), add(alphaBias.setFrozen(false), input)), add(new LinearActivationLayer().setScale(2).freeze(), add(new SigmoidActivationLayer().setBalanced(false), gateNode)));
                            break;
                        }
                    case Bilinear:
                        {
                            final DAGNode gateNode = add(gate.setFrozen(false), null != gateBias ? add(gateBias.setFrozen(false), input) : input);
                            head = add(new SumInputsLayer(), add(new ProductInputsLayer(), add(alpha.setFrozen(false), add(alphaBias.setFrozen(false), input)), add(new SigmoidActivationLayer().setBalanced(false), gateNode)), add(new ProductInputsLayer(), add(beta.setFrozen(false), add(betaBias.setFrozen(false), input)), add(new SigmoidActivationLayer().setBalanced(false), add(new LinearActivationLayer().setScale(-1).freeze(), gateNode))));
                            break;
                        }
                    case Final:
                        final DAGNode gateNode = add(gate.setFrozen(false), null != gateBias ? add(gateBias.setFrozen(false), input) : input);
                        head = add(new SumInputsLayer(), add(new ProductInputsLayer(), add(alpha, input), add(new SigmoidActivationLayer().setBalanced(false), gateNode)), add(new ProductInputsLayer(), add(beta, input), add(new SigmoidActivationLayer().setBalanced(false), add(new LinearActivationLayer().setScale(-1).freeze(), gateNode))));
                        break;
                }
            }
        }
    }
    return head;
}
Also used : SumInputsLayer(com.simiacryptus.mindseye.layers.java.SumInputsLayer) DAGNode(com.simiacryptus.mindseye.network.DAGNode) SigmoidActivationLayer(com.simiacryptus.mindseye.layers.java.SigmoidActivationLayer) ProductInputsLayer(com.simiacryptus.mindseye.layers.java.ProductInputsLayer) LinearActivationLayer(com.simiacryptus.mindseye.layers.java.LinearActivationLayer) Nullable(javax.annotation.Nullable)

Aggregations

LinearActivationLayer (com.simiacryptus.mindseye.layers.java.LinearActivationLayer)1 ProductInputsLayer (com.simiacryptus.mindseye.layers.java.ProductInputsLayer)1 SigmoidActivationLayer (com.simiacryptus.mindseye.layers.java.SigmoidActivationLayer)1 SumInputsLayer (com.simiacryptus.mindseye.layers.java.SumInputsLayer)1 DAGNode (com.simiacryptus.mindseye.network.DAGNode)1 Nullable (javax.annotation.Nullable)1