-
Notifications
You must be signed in to change notification settings - Fork 8
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
completed lstm #71
completed lstm #71
Changes from 4 commits
abfceb9
9a7e0a4
24d6d03
8d6e71e
95c0ab1
6995143
bda1651
c451f91
cf52d51
190fe60
76746d9
d8ebc93
5b098bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||
'use strict'; | ||||||
|
||||||
import {Tensor, sizeOfShape} from './lib/tensor.js'; | ||||||
import {validateSqueezeParams} from './lib/validate-input.js'; | ||||||
|
||||||
/** | ||||||
* Alter the shape of a tensor to a new shape. | ||||||
|
@@ -31,3 +32,19 @@ export function reshape(input, newShape) { | |||||
const output = new Tensor(outputShape, input.data); | ||||||
return output; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Reduce the rank of a tensor by eliminating dimensions with size 1 of the tensor shape. | ||||||
* @param {Tensor} input | ||||||
* @param {MLSqueezeOptions} options | ||||||
* @return {Tensor} | ||||||
*/ | ||||||
export function squeeze(input, {axes} = {}) { | ||||||
validateSqueezeParams(...arguments); | ||||||
const inpAxes = axes ?? new Array(input.rank).fill(0).map((_, i) => i); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Hmm, kinda confusing way of initializing a sequence by chaining multiple methods together (took me a bit to figure out), rather than just saying |
||||||
|
||||||
const outputShape = input.shape.filter((dim, axis) => | ||||||
!(dim === 1 && inpAxes.indexOf(axis) !== -1)); | ||||||
const output = reshape(input, outputShape); | ||||||
return output; | ||||||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whole word identifiers are more readable for others later (and it's consistent with
input.rank
rather thaninp.rank
).