tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.51k stars 1.94k forks source link

The accuracy of speechcommands transfer leanring is too low #3121

Closed yunyunsan closed 4 years ago

yunyunsan commented 4 years ago

When I used the code provided by https://codelabs.developers.google.com/codelabs/tensorflowjs-audio-codelab/index.html#0 to test, I found that the accuracy is too low and it is sensitive to any sound. After that I added the following code to function buildModel (), but the problem is still not solved. function buildModel() { model = tf.sequential(); model.add(tf.layers.conv2d( {filters: 8, kernelSize: [2, 8],strides: [1, 1], activation: 'relu', inputShape: INPUT_SHAPE,})); model.add(tf.layers.maxPooling2d({poolSize: [2, 2], strides: [2, 2]})); model.add( tf.layers.conv2d({filters: 32, kernelSize: [2, 4],strides: [1, 1], activation: 'relu'})); model.add(tf.layers.maxPooling2d({poolSize: [2, 2], strides: [2, 2]})); model.add( tf.layers.conv2d({filters: 32, kernelSize: [2, 4], activation: 'relu'})); model.add(tf.layers.maxPooling2d({poolSize: [2, 2], strides: [2, 2]})); model.add( tf.layers.conv2d({filters: 32, kernelSize: [2, 4], activation: 'relu'})); model.add(tf.layers.maxPooling2d({poolSize: [2, 2], strides: [1, 2]})); model.add(tf.layers.flatten()); model.add(tf.layers.dropout({rate: 0.25})); model.add(tf.layers.dense({units: 2000, activation: 'relu'})); model.add(tf.layers.dropout({rate: 0.5})); model.add(tf.layers.dense({units: 3, activation: 'softmax'})); const optimizer = tf.train.adam(0.01); model.compile({ optimizer, loss: 'categoricalCrossentropy', metrics: ['accuracy'] }); } Or is my thinking wrong? So can I get some suggestions from here, I think that would be a great inspiration for my next direction. Thank you very much and hope to get a reply.

tafsiri commented 4 years ago

@yunyunsan I think this question is a bit too broad for github issues. I think posting to stackoverflow or the community mailing list would be a better fit, since its less about a bug and more about general improvements to an application. So i'm going to close the issue here, if you believe there is a bug in tfjs related to this feel free to request we re-open this.

That said, my suggestion would be to collect more diverse samples for the "noise" class.

yunyunsan commented 4 years ago

@tafsiri Thank you very much for your reply