use of com.simiacryptus.mindseye.layers.java.ProductInputsLayer 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;
}
Aggregations