-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The model data has been separated from the estimation algorithm
- Loading branch information
Showing
22 changed files
with
508 additions
and
538 deletions.
There are no files selected for viewing
64 changes: 42 additions & 22 deletions
64
examples/estimator/classifier/MLPClassifier/java/basics.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
62 changes: 41 additions & 21 deletions
62
examples/estimator/classifier/MLPClassifier/java/basics.py
Large diffs are not rendered by default.
Oops, something went wrong.
148 changes: 67 additions & 81 deletions
148
examples/estimator/classifier/MLPClassifier/js/basics.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
150 changes: 68 additions & 82 deletions
150
examples/estimator/classifier/MLPClassifier/js/basics.py
Large diffs are not rendered by default.
Oops, something went wrong.
100 changes: 43 additions & 57 deletions
100
examples/estimator/regressor/MLPRegressor/js/basics.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/activation_fn.identity.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Activation function (identity): | ||
public static double[] compAct(double[] v) { | ||
private double[] compAct(double[] v) { | ||
return v; | ||
} |
2 changes: 1 addition & 1 deletion
2
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/activation_fn.logistic.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/activation_fn.relu.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/activation_fn.tanh.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/method.binary.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 16 additions & 16 deletions
32
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/method.multi.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/output_fn.logistic.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
sklearn_porter/estimator/classifier/MLPClassifier/templates/java/output_fn.softmax.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 16 additions & 22 deletions
38
sklearn_porter/estimator/classifier/MLPClassifier/templates/js/method.binary.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
// Model data: | ||
const {coefficients} | ||
const {intercepts} | ||
this.{method_name} = function(neurons) {{ | ||
if (neurons.length != {n_features}) return -1; | ||
var network = [neurons].concat(layers); | ||
|
||
return {{ | ||
{method_name}: function(atts) {{ | ||
if (atts.length != {n_features}) {{ return -1; }}; | ||
var {layers} | ||
|
||
for (var i = 0; i < layers.length - 1; i++) {{ | ||
for (var j = 0; j < layers[i + 1].length; j++) {{ | ||
for (var l = 0; l < layers[i].length; l++) {{ | ||
layers[i + 1][j] += layers[i][l] * COEFFICIENTS[i][l][j]; | ||
}} | ||
layers[i + 1][j] += INTERCEPTS[i][j]; | ||
}} | ||
if ((i + 1) < (layers.length - 1)) {{ | ||
layers[i + 1] = compAct(layers[i + 1]); | ||
for (var i = 0; i < network.length - 1; i++) {{ | ||
for (var j = 0; j < network[i + 1].length; j++) {{ | ||
for (var l = 0; l < network[i].length; l++) {{ | ||
network[i + 1][j] += network[i][l] * weights[i][l][j]; | ||
}} | ||
network[i + 1][j] += bias[i][j]; | ||
}} | ||
layers[layers.length - 1] = compOut(layers[layers.length - 1]); | ||
|
||
if (layers[layers.length - 1][0] > .5) {{ | ||
return 1; | ||
if ((i + 1) < (network.length - 1)) {{ | ||
network[i + 1] = compAct(network[i + 1]); | ||
}} | ||
return 0; | ||
}} | ||
network[network.length - 1] = compOut(network[network.length - 1]); | ||
|
||
if (network[network.length - 1][0] > .5) {{ | ||
return 1; | ||
}} | ||
return 0; | ||
}}; |
Oops, something went wrong.