-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
576 additions
and
313 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,8 @@ | |
### QuickStart | ||
|
||
This example shows how to train a neural network to predict the output of the | ||
XOR function our speedy CPU backend written in [Rust](https://www.rust-lang.org/). | ||
XOR function our speedy CPU backend written in | ||
[Rust](https://www.rust-lang.org/). | ||
|
||
```typescript | ||
import { | ||
|
@@ -253,7 +254,7 @@ console.log(`1 xor 1 = ${out4[0]} (should be close to 0)`); | |
### Documentation | ||
|
||
The full documentation for Netsaur can be found | ||
[here](https://deno.land/x/[email protected].0/mod.ts). | ||
[here](https://deno.land/x/[email protected].1/mod.ts). | ||
|
||
### License | ||
|
||
|
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
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,7 +1,7 @@ | ||
[package] | ||
edition = "2021" | ||
name = "netsaur" | ||
version = "0.3.0" | ||
version = "0.3.1" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { CsvParseStream } from "https://deno.land/[email protected]/csv/csv_parse_stream.ts"; | ||
export { CsvParseStream } from "jsr:@std/csv@0.214.0"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { dlopen } from "https://deno.land/x/[email protected]/mod.ts"; | ||
export type { FetchOptions } from "https://deno.land/x/[email protected]/mod.ts"; | ||
export { dlopen } from "jsr:@denosaurs/[email protected]"; | ||
export type { FetchOptions } from "jsr:@denosaurs/[email protected]"; |
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,3 +1,4 @@ | ||
# Binary Classification | ||
This example showcases binary classification on the Iris dataset. | ||
The `Iris Virginica` class is omitted for this example. | ||
|
||
This example showcases binary classification on the Iris dataset. The | ||
`Iris Virginica` class is omitted for this example. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,12 @@ import { parse } from "https://deno.land/[email protected]/csv/parse.ts"; | |
|
||
// Import helpers for metrics | ||
import { | ||
ClassificationReport, | ||
// Split the dataset | ||
useSplit, | ||
// One-hot encoding of targets | ||
CategoricalEncoder, | ||
ClassificationReport, | ||
Matrix, | ||
// Split the dataset | ||
useSplit, | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
// Read the training dataset | ||
|
@@ -40,7 +40,7 @@ const y = encoder.fit(y_pre).transform(y_pre, "f32"); | |
// @ts-ignore Matrices can be split | ||
const [train, test] = useSplit({ ratio: [7, 3], shuffle: true }, x, y) as [ | ||
[typeof x, typeof y], | ||
[typeof x, typeof y] | ||
[typeof x, typeof y], | ||
]; | ||
|
||
// Setup the CPU backend for Netsaur | ||
|
@@ -87,7 +87,7 @@ net.train( | |
// Train for 300 epochs | ||
400, | ||
1, | ||
0.02 | ||
0.02, | ||
); | ||
|
||
console.log(`training time: ${performance.now() - time}ms`); | ||
|
@@ -96,8 +96,8 @@ console.log(`training time: ${performance.now() - time}ms`); | |
const res = await net.predict(tensor2D(test[0])); | ||
const y1 = encoder.untransform( | ||
CategoricalEncoder.fromSoftmax( | ||
new Matrix(res.data, [res.shape[0], res.shape[1]]) | ||
) | ||
new Matrix(res.data, [res.shape[0], res.shape[1]]), | ||
), | ||
); | ||
const y0 = encoder.untransform(test[1]); | ||
|
||
|
@@ -106,5 +106,5 @@ const cMatrix = new ClassificationReport(y0, y1); | |
console.log(cMatrix); | ||
console.log( | ||
"Total Accuracy: ", | ||
y1.filter((x, i) => x === y0[i]).length / y1.length | ||
y1.filter((x, i) => x === y0[i]).length / y1.length, | ||
); |
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
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
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 |
---|---|---|
|
@@ -63,19 +63,19 @@ | |
} | ||
], | ||
"source": [ | ||
"import { tensor1D } from \"https://deno.land/x/[email protected].0/mod.ts\";\n", | ||
"import { Visualizer } from \"https://deno.land/x/[email protected].0/visualizer/mod.ts\";\n", | ||
"import { tensor1D } from \"https://deno.land/x/[email protected].1/mod.ts\";\n", | ||
"import { Visualizer } from \"https://deno.land/x/[email protected].1/visualizer/mod.ts\";\n", | ||
"\n", | ||
"import {\n", | ||
" Cost,\n", | ||
" AUTO,\n", | ||
" Cost,\n", | ||
" DenseLayer,\n", | ||
" Sequential,\n", | ||
" setupBackend,\n", | ||
" SigmoidLayer,\n", | ||
" tensor2D,\n", | ||
"} from \"https://deno.land/x/[email protected].0/mod.ts\";\n", | ||
" \n", | ||
"} from \"https://deno.land/x/[email protected].1/mod.ts\";\n", | ||
"\n", | ||
"await setupBackend(AUTO);\n", | ||
"\n", | ||
"const net = new Sequential({\n", | ||
|
@@ -107,10 +107,9 @@ | |
" ],\n", | ||
" 1000000,\n", | ||
");\n", | ||
" \n", | ||
"\n", | ||
"const visualizer = new Visualizer(\"XOR Example\");\n", | ||
"await visualizer.graph(net,\n", | ||
" [\n", | ||
"await visualizer.graph(net, [\n", | ||
" tensor1D([0, 0]),\n", | ||
" tensor1D([1, 0]),\n", | ||
" tensor1D([0, 1]),\n", | ||
|
@@ -119,8 +118,8 @@ | |
" tensor1D([0]),\n", | ||
" tensor1D([1]),\n", | ||
" tensor1D([1]),\n", | ||
" tensor1D([0])\n", | ||
"])" | ||
" tensor1D([0]),\n", | ||
"]);" | ||
] | ||
} | ||
], | ||
|
Oops, something went wrong.