Skip to content

Commit

Permalink
chore: bump deps (#60) (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
load1n9 authored Sep 7, 2024
1 parent 7cc0b82 commit 7d5d206
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 287 deletions.
29 changes: 23 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@
package.version = "0.4.0"
members = ["crates/*"]
resolver = "2"

[workspace.dependencies]
cudarc = "0.9.14"
ndarray = "0.16.1"
ndarray-rand = "0.15.0"
safetensors = "0.4.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0.49"
96 changes: 29 additions & 67 deletions bench/netsaur_cpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,72 +11,34 @@ import {

await setupBackend(CPU);

Deno.bench(
{ name: "xor 10000 epochs", permissions: "inherit" },
async () => {
const net = new Sequential({
size: [4, 2],
silent: true,
layers: [
DenseLayer({ size: [3] }),
SigmoidLayer(),
DenseLayer({ size: [1] }),
SigmoidLayer(),
],
cost: Cost.MSE,
});

net.train(
[
{
inputs: tensor2D([
[0, 0],
[1, 0],
[0, 1],
[1, 1],
]),
outputs: tensor2D([[0], [1], [1], [0]]),
},
],
10000,
);

console.log((await net.predict(tensor1D([0, 0]))).data);
console.log((await net.predict(tensor1D([1, 0]))).data);
console.log((await net.predict(tensor1D([0, 1]))).data);
console.log((await net.predict(tensor1D([1, 1]))).data);
},
const net = new Sequential({
size: [4, 2],
silent: true,
layers: [
DenseLayer({ size: [3] }),
SigmoidLayer(),
DenseLayer({ size: [1] }),
SigmoidLayer(),
],
cost: Cost.MSE,
});

net.train(
[
{
inputs: tensor2D([
[0, 0],
[1, 0],
[0, 1],
[1, 1],
]),
outputs: tensor2D([[0], [1], [1], [0]]),
},
],
10000,
);

// const net = new NeuralNetwork({
// size: [4, 2],
// silent: true,
// layers: [
// DenseLayer({ size: [3], activation: Activation.Sigmoid }),
// DenseLayer({ size: [1], activation: Activation.Sigmoid }),
// ],
// cost: Cost.MSE,
// });

// const time = performance.now();

// net.train(
// [
// {
// inputs: tensor2D([
// [0, 0],
// [1, 0],
// [0, 1],
// [1, 1],
// ]),
// outputs: tensor2D([[0], [1], [1], [0]]),
// },
// ],
// 10000,
// )

// console.log(`training time: ${performance.now() - time}ms`);
// console.log((await net.predict(tensor2D([[0, 0]]))).data);
// console.log((await net.predict(tensor2D([[1, 0]]))).data);
// console.log((await net.predict(tensor2D([[0, 1]]))).data);
// console.log((await net.predict(tensor2D([[1, 1]]))).data);
console.log((await net.predict(tensor1D([0, 0]))).data);
console.log((await net.predict(tensor1D([1, 0]))).data);
console.log((await net.predict(tensor1D([0, 1]))).data);
console.log((await net.predict(tensor1D([1, 1]))).data);
96 changes: 29 additions & 67 deletions bench/netsaur_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,72 +11,34 @@ import {

await setupBackend(WASM);

Deno.bench(
{ name: "xor 10000 epochs", permissions: "inherit" },
async () => {
const net = new Sequential({
size: [4, 2],
silent: true,
layers: [
DenseLayer({ size: [3] }),
SigmoidLayer(),
DenseLayer({ size: [1] }),
SigmoidLayer(),
],
cost: Cost.MSE,
});

net.train(
[
{
inputs: tensor2D([
[0, 0],
[1, 0],
[0, 1],
[1, 1],
]),
outputs: tensor2D([[0], [1], [1], [0]]),
},
],
10000,
);

console.log((await net.predict(tensor1D([0, 0]))).data);
console.log((await net.predict(tensor1D([1, 0]))).data);
console.log((await net.predict(tensor1D([0, 1]))).data);
console.log((await net.predict(tensor1D([1, 1]))).data);
},
const net = new Sequential({
size: [4, 2],
silent: true,
layers: [
DenseLayer({ size: [3] }),
SigmoidLayer(),
DenseLayer({ size: [1] }),
SigmoidLayer(),
],
cost: Cost.MSE,
});

net.train(
[
{
inputs: tensor2D([
[0, 0],
[1, 0],
[0, 1],
[1, 1],
]),
outputs: tensor2D([[0], [1], [1], [0]]),
},
],
10000,
);

// const net = new NeuralNetwork({
// size: [4, 2],
// silent: true,
// layers: [
// DenseLayer({ size: [3], activation: Activation.Sigmoid }),
// DenseLayer({ size: [1], activation: Activation.Sigmoid }),
// ],
// cost: Cost.MSE,
// });

// const time = performance.now();

// net.train(
// [
// {
// inputs: tensor2D([
// [0, 0],
// [1, 0],
// [0, 1],
// [1, 1],
// ]),
// outputs: tensor2D([[0], [1], [1], [0]]),
// },
// ],
// 10000,
// )

// console.log(`training time: ${performance.now() - time}ms`);
// console.log((await net.predict(tensor2D([[0, 0]]))).data);
// console.log((await net.predict(tensor2D([[1, 0]]))).data);
// console.log((await net.predict(tensor2D([[0, 1]]))).data);
// console.log((await net.predict(tensor2D([[1, 1]]))).data);
console.log((await net.predict(tensor1D([0, 0]))).data);
console.log((await net.predict(tensor1D([1, 0]))).data);
console.log((await net.predict(tensor1D([0, 1]))).data);
console.log((await net.predict(tensor1D([1, 1]))).data);
27 changes: 0 additions & 27 deletions bench/node/brain_cpu.js

This file was deleted.

26 changes: 0 additions & 26 deletions bench/node/brain_gpu.js

This file was deleted.

18 changes: 0 additions & 18 deletions bench/node/package.json

This file was deleted.

23 changes: 0 additions & 23 deletions bench/node/tfjs_cpu.js

This file was deleted.

15 changes: 7 additions & 8 deletions crates/core-gpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ version = { workspace = true }
[lib]
crate-type = ["cdylib"]


[dependencies]
ndarray = "0.15.6"
ndarray-rand = "0.14.0"
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0"
safetensors = "0.4.0"
cudarc = "0.9.14"
thiserror = "1.0.49"
cudarc = { workspace = true }
ndarray = { workspace = true }
ndarray-rand = { workspace = true }
safetensors = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
Loading

0 comments on commit 7d5d206

Please sign in to comment.