Skip to content

Add custom loss functions and a R/W state matrix #936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ee5fc8d
Implement a loss function for GPU
ashenmagic Jun 15, 2024
6baf8c6
Add partial support for loss functions
ashenmagic Jun 16, 2024
eb909c9
Update loss.ts
ashenmagic Jun 16, 2024
1f2c681
OMG OMG OMG!!!!!! ZOOOOOMIESSS <3333
ashenmagic Jun 16, 2024
ba12f82
Fixed the bug~! <3
ashenmagic Jun 16, 2024
7371a23
Generalize loss function for both CPU and GPU
ashenmagic Jun 16, 2024
2a7840a
Add memory function
ashenmagic Jun 16, 2024
a762a48
Backup: Another thunderstorm, power outage risk
ashenmagic Jun 16, 2024
94fc99a
Revert "Backup: Another thunderstorm, power outage risk"
ashenmagic Jun 16, 2024
ba03eb3
Add parameter `lossDelta`
ashenmagic Jun 16, 2024
aa337f3
Rename memory to RAM
ashenmagic Jun 16, 2024
c655c52
Add `updateRAM`
ashenmagic Jun 17, 2024
b45d581
Fix bug that required `ramSize` to be defined
ashenmagic Jun 17, 2024
b703e4a
Prune unused code
ashenmagic Jun 17, 2024
fda0349
Run `updateRAM` on both CPU and GPU nets
ashenmagic Jun 17, 2024
3d392f1
Design custom loss function for autoencoders
ashenmagic Jun 17, 2024
ce98bf1
Fix CI task errors
ashenmagic Jun 17, 2024
51b9aa9
Fix a CI task related to type coersion
ashenmagic Jun 17, 2024
c5c8438
TypeScript hates me today
ashenmagic Jun 17, 2024
e8384a5
Fix all lint errors
ashenmagic Jun 17, 2024
a21c387
Remove unused `@ts-expect-error` directive
ashenmagic Jun 17, 2024
83574f6
Please, linter gods, pleaaaase stop hating me
ashenmagic Jun 17, 2024
52edc88
Properly initialize `NeuralNetwork.ram`
ashenmagic Jun 18, 2024
8f8f455
Finish updating autoencoder to use loss function
ashenmagic Jun 18, 2024
00b8515
Add a CPU variant of autoencoder
ashenmagic Jun 18, 2024
e4e6906
Polish autoencoders and remove debug code
ashenmagic Jun 18, 2024
4d7b5ef
Remove debug code
ashenmagic Jun 18, 2024
cd0ad75
Export the CPU autoencoder implementation
ashenmagic Jun 18, 2024
693bd0b
Update tests and documentation
ashenmagic Jun 19, 2024
a03161f
Merge branch 'main' into feature/loss-function
ashenmagic Nov 6, 2024
561dda3
Remove duplicate lines added during merge
ashenmagic Dec 29, 2024
42aece2
Resolve nested tests
ashenmagic Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Resolve nested tests
  • Loading branch information
ashenmagic committed Jan 3, 2025
commit 42aece22c9be15bb824467c6025f5d1446e147d2
50 changes: 22 additions & 28 deletions src/autoencoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,30 @@ test('denoise a data sample', async () => {

test('encode and decode a data sample', async () => {
expect(result.error).toBeLessThanOrEqual(errorThresh);
test('encode and decode a data sample', async () => {
expect(result.error).toBeLessThanOrEqual(errorThresh);

const run1$input = [0, 0, 0];
const run1$encoded = xornet.encode(run1$input);
const run1$decoded = xornet.decode(run1$encoded);

const run2$input = [0, 1, 1];
const run2$encoded = xornet.encode(run2$input);
const run2$decoded = xornet.decode(run2$encoded);

for (let i = 0; i < 3; i++)
expect(Math.round(run1$decoded[i])).toBe(run1$input[i]);
for (let i = 0; i < 3; i++)
expect(Math.round(run2$decoded[i])).toBe(run2$input[i]);
});

const run1$input = [0, 0, 0];
const run1$encoded = xornet.encode(run1$input);
const run1$decoded = xornet.decode(run1$encoded);

const run2$input = [0, 1, 1];
const run2$encoded = xornet.encode(run2$input);
const run2$decoded = xornet.decode(run2$encoded);

for (let i = 0; i < 3; i++)
expect(Math.round(run1$decoded[i])).toBe(run1$input[i]);
for (let i = 0; i < 3; i++)
expect(Math.round(run2$decoded[i])).toBe(run2$input[i]);
});

test('test a data sample for anomalies', async () => {
expect(result.error).toBeLessThanOrEqual(errorThresh);
test('test a data sample for anomalies', async () => {
expect(result.error).toBeLessThanOrEqual(errorThresh);

function likelyIncludesAnomalies(...args: number[]) {
expect(xornet.likelyIncludesAnomalies(args, 0.5)).toBe(false);
}

likelyIncludesAnomalies(0, 0, 0);
likelyIncludesAnomalies(0, 1, 1);
likelyIncludesAnomalies(1, 0, 1);
likelyIncludesAnomalies(1, 1, 0);
});

function likelyIncludesAnomalies(...args: number[]) {
expect(xornet.likelyIncludesAnomalies(args, 0.5)).toBe(false);
}

likelyIncludesAnomalies(0, 0, 0);
likelyIncludesAnomalies(0, 1, 1);
likelyIncludesAnomalies(1, 0, 1);
likelyIncludesAnomalies(1, 1, 0);
});
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy