-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish loss utils function, add to package, bump version
- Loading branch information
1 parent
d17dd6a
commit e562d2b
Showing
10 changed files
with
25 additions
and
24 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import { Value } from '.'; | ||
export declare function toValues(arr: number[]): Value[]; | ||
export declare const getLoss: (ygt: Value[], ypred: Value[]) => Value; |
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,8 +1,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toValues = void 0; | ||
exports.getLoss = exports.toValues = void 0; | ||
const _1 = require("."); | ||
function toValues(arr) { | ||
return arr.map((x) => new _1.Value(x)); | ||
} | ||
exports.toValues = toValues; | ||
const getLoss = (ygt, ypred) => { | ||
let result = new _1.Value(0); | ||
for (let i = 0; i < ygt.length; i++) { | ||
result = (0, _1.add)(result, (0, _1.mul)((0, _1.sub)(ygt[i], ypred[i]), (0, _1.sub)(ygt[i], ypred[i]))); | ||
} | ||
return result; | ||
}; | ||
exports.getLoss = getLoss; |
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,5 +1,13 @@ | ||
import { Value } from '.'; | ||
import { Value, add, mul, sub } from '.'; | ||
|
||
export function toValues(arr: number[]): Value[] { | ||
return arr.map((x) => new Value(x)); | ||
} | ||
|
||
export const getLoss = (ygt: Value[], ypred: Value[]) => { | ||
let result = new Value(0); | ||
for (let i = 0; i < ygt.length; i++) { | ||
result = add(result, mul(sub(ygt[i], ypred[i]), sub(ygt[i], ypred[i]))); | ||
} | ||
return result; | ||
}; |