-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fixing up assess(...) function #558
Conversation
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.
thanks very much for the changes and bugfix :)
const model = await this.getModel() | ||
|
||
let features: Array<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][]> = [] |
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.
the xs
vector is always a batch of samples, hence we usually directly cast it as number[][]
to avoid carrying TF.js's bad typing
const ys = this.getLabel(e.ys as tf.Tensor) | ||
const pred = this.getLabel(model.predict(xs, { batchSize: batchSize }) as tf.Tensor) | ||
|
||
const currentFeatures = xs.arraySync() |
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.
you might have to cast the result of arraySync
to number[][]
for the reason mentioned above :)
const currentFeatures = xs.arraySync() | ||
|
||
if (Array.isArray(currentFeatures)) { | ||
features = [...features, ...currentFeatures] |
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.
a = a.concat(b)
throw new TypeError('features array is not correct') | ||
} | ||
|
||
groundTruth.push(...Array.from(ys)) |
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.
maybe getLabel
could call arraySync
instead of dataSync
(and cast) to avoid manually constructing an array
No description provided.