Skip to content

Comments

Fixing up assess(...) function#558

Merged
s314cy merged 3 commits intodevelopfrom
nan-assess-function-fixup
Jan 4, 2023
Merged

Fixing up assess(...) function#558
s314cy merged 3 commits intodevelopfrom
nan-assess-function-fixup

Conversation

@francesco98
Copy link
Collaborator

No description provided.

@francesco98 francesco98 marked this pull request as ready for review December 28, 2022 17:32
@s314cy s314cy self-requested a review December 29, 2022 14:57
@s314cy s314cy self-assigned this Dec 29, 2022
@s314cy s314cy added bug Something isn't working web client Related to the browser environment discojs Related to Disco.js labels Dec 29, 2022
Copy link
Contributor

@s314cy s314cy left a 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[][][][][]> = []
Copy link
Contributor

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()
Copy link
Contributor

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]
Copy link
Contributor

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))
Copy link
Contributor

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

@s314cy s314cy self-requested a review January 4, 2023 15:52
@s314cy s314cy merged commit b6d18b9 into develop Jan 4, 2023
@s314cy s314cy deleted the nan-assess-function-fixup branch January 4, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working discojs Related to Disco.js web client Related to the browser environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants