public NonLinearCliquePotentialFunction(double[][] linearWeights, double[][] inputLayerWeights, double[][] outputLayerWeights, SeqClassifierFlags flags) { this.linearWeights = linearWeights; this.inputLayerWeights = inputLayerWeights; this.outputLayerWeights = outputLayerWeights; this.flags = flags; }
public NonLinearSecondOrderCliquePotentialFunction(double[][] inputLayerWeights4Edge, double[][] outputLayerWeights4Edge, double[][] inputLayerWeights, double[][] outputLayerWeights, SeqClassifierFlags flags) { this.inputLayerWeights4Edge = inputLayerWeights4Edge; this.outputLayerWeights4Edge = outputLayerWeights4Edge; this.inputLayerWeights = inputLayerWeights; this.outputLayerWeights = outputLayerWeights; this.flags = flags; }
public virtual double[] HiddenLayerOutput(double[][] inputLayerWeights, int[] nodeCliqueFeatures, SeqClassifierFlags aFlag, double[] featureVal) { int layerOneSize = inputLayerWeights.Length; if (layerOneCache == null || layerOneSize != layerOneCache.Length) layerOneCache = new double[layerOneSize]; for (int i = 0; i < layerOneSize; i++) { double[] ws = inputLayerWeights[i]; double lOneW = 0; double dotProd = 0; for (int m = 0; m < nodeCliqueFeatures.Length; m++) { dotProd = ws[nodeCliqueFeatures[m]]; if (featureVal != null) dotProd *= featureVal[m]; lOneW += dotProd; } layerOneCache[i] = lOneW; } if (!aFlag.useHiddenLayer) return layerOneCache; if (hiddenLayerCache == null || layerOneSize != hiddenLayerCache.Length) hiddenLayerCache = new double[layerOneSize]; for (int i = 0; i < layerOneSize; i++) { if (aFlag.useSigmoid) { hiddenLayerCache[i] = Sigmoid(layerOneCache[i]); } else { hiddenLayerCache[i] = System.Math.Tanh(layerOneCache[i]); } } return hiddenLayerCache; }