-
Notifications
You must be signed in to change notification settings - Fork 43
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
use nn.Embedding() to handle emg_data #55
Comments
Without looking at the code so far: Are you using the curated sessions only to measure results? I'd recommend using a sliding window to preprocess the raw EMG datasamples using a filter of sorts. About 30-100 samples as filter size and using the root mean square (RMS) equation. Let me know how it goes or if you need additional help. |
What do you mean by sliding window and RMS processing? Indeed, I think it's a problem with data preprocessing. When it's not 0.txt, I also loaded all the tags in. Is this incorrect? |
I've just open sourced the solution in Keras if you need it: https://github.com/aljazfrancic/myo-keras/blob/master/myo-keras.ipynb it has RMS implementation in it too. |
Many thanks,I will try. Will you use other model like LSTM, Transformer to predict the result? |
No, a simple multilayer perceptron should suffice for this task I think. |
I'm interested in your results and repo, if you are willing to share. |
I just experimented with your algorithm in PyTorch. Its accuracy is around 80%, which is still a bit low. My scene is music interaction, so I want to achieve a higher accuracy to better control live sound effects, etc. Do you directly use the results of each judgment in actual engineering? For example, if I make a fist, do I need to collect data based on the window length? Is collecting once enough? |
For real time control you will require a buffer (que) to store at least the window size of EMG samples. For example if you have window size 40 samples you would keep the last 40 EMG samples in your buffer and do the calculations of RMS on those. Then on next sample remove the oldest of 40 samples and add newest sample. For the first few moments when you don't have samples you can use whatever samples you have or skip this in training and evaluation. |
|
Sounds good if you only need 1 action per second on your output. |
Here‘s my newest code. I am trying using sequence to sequence model to solve that problem. And the following is my results of experiment. The highest accuracy is approximately 89% (overfitted).
I want to use this method because the window length for this experiment is 50. Therefore, it is necessary to take 4 results, and in the final generated sequence (batch size=1, timestep=50, features_num=8), select the index (torch.argmax(**,dim = -1))with the most occurrences as the prediction result. Take 4 consecutive times, and if they are consistent, perform the [index] action in that second. What do you think? Thank you for your continuous help and I hope to hear your suggestions! |
Since you have 1 second of EMG, you could also have 1 second of RMS values. You are now only using 5 values out of 200 available, if I understand your method correctly. So maybe you could just check which class/gesture has the most classifications in 200 last samples of classification from RMS. Do you know what I mean? Another thing that I would like to point out that there is a difference between training and validation loss and accuracy. If you have 89 % accuracy on validation set that doesn't mean if was overfitting. That's a good result. Just make sure to always use the model from step that had the lowest validation loss. Nice results, BTW. I don't think its possible to push them much further due to the fact that recordings also include the areas of switching between gestures, and are by no means perfect. |
I guess the idea is to low-pass filter both the input into the into the neural net (EMG → RMS) as well as the result you get from it (classification → mode of classification). I'd just use mode to calculate the resulting classification from last 200 samples of classification (the mode is the number that occurs most often in last second of classification). |
It's not entirely like this. I split 200 output values (in 1 second) into every 50 values. When the number of output values is less than 50, I use a sequence (0,0,0,0,0,0,0,0) with a label of 0 to fill in and put it into the sequence model. Therefore, the output of one batch size will have 50 labels. Due to the use of cross entropy for multi classification in my training (unlike Keras), I need to reduce the dimensionality of the input sequence tensor from 3D to 2D and the labels from 2D to 1D. Therefore, the accuracy is based on the results of batch size * 50. In practical application scenarios, batch size=1, so there are both correct and incorrect situations in these labels. Setting aside the incorrect situations, there will also be 0 occurrences. Because the dataset is based on periodic collection, there are also events with a label of 0 occurring in addition to the text in 0.txt. But I think the result should approach the mode of 50 output results, so the mode can be taken as the result of 1/4 second. When the result is the same for four consecutive times, I think this action has occurred. Of course, the results obtained from the experiment are exciting and can serve as a reference, but currently I have not written test code or used the Myo armband provided by my teacher for further verification. |
Sounds good, I think I misunderstood a little what you are doing. Best
wishes!
…On Sat, Oct 19, 2024, 13:28 shiyi099 ***@***.***> wrote:
Since you have 1 second of EMG, you could also have 1 second of RMS
values. You are now only using 5 values out of 200 available, if I
understand your method correctly. So maybe you could just check which
class/gesture has the most classifications in 200 last samples of
classification from RMS. Do you know what I mean? Another thing that I
would like to point out that there is a difference between training and
validation loss and accuracy. If You have 89 % accuracy on validation set
that doesn't mean if was overfitting. That's a good result. Just make sure
to always use the model from step that had the lowest validation loss. Nice
results, BTW. I don't think its possible to push them much further due to
the fact that recordings also include the areas of switching between
gestures, and are by no means perfect.
It's not entirely like this. I split 200 output values (in 1 second) into
every 50 values. When the number of output values is less than 50, I use a
sequence (0,0,0,0,0,0,0,0) with a label of 0 to fill in and put it into the
sequence model. Therefore, the output of one batch size will have 50
labels. Due to the use of cross entropy for multi classification in my
training (unlike Keras), I need to reduce the dimensionality of the input
sequence tensor from 3D to 2D and the labels from 2D to 1D. Therefore, the
accuracy is based on the results of batch size * 50. In practical
operation, batchsize=1, so there are both correct and incorrect situations
in these labels. Setting aside the incorrect situations, there will also be
0 occurrences. Because the dataset is based on periodic collection, there
are also events with a label of 0 occurring in addition to the text in
0.txt. But I think the result should approach the mode of 50 output
results, so the mode can be taken as the result of 1/4 second. When the
result is the same for four consecutive times, I think this action has
occurred. Of course, the results obtained from the experiment are exciting
and can serve as a reference, but currently I have not written test code or
used the Myo ArmBand provided by my teacher for further verification.
—
Reply to this email directly, view it on GitHub
<#55 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEIL7DXXXFE36SK5YD5B62LZ4I653AVCNFSM6AAAAABQGGX4ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRTG43TIMJTHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I am a rookie in signal processing, lol |
A particularly pleasant conversation, thank you for your patient response and assistance with the materials. I hope we can have almost cooperation in the future!
A particularly pleasant conversation, thank you for your patient response and assistance with the materials. I hope we can have almost cooperation in the future! |
We have tried both PCA and ICA for better feature extraction but alas at no benefit. The pipeline was: EMG, RMS, PCA/ICA, neural net inputs and outputs. We of course tried different window sizes for RMS. I think best value is between 30-80, depending on how fast you want feedback from your system. You can substitute RMS with simple addition of absolute values and that works too. |
Copy that. Many thanks! |
Will it be better when I use nn.Embedding(num_embeddings=256) to handle emg_data? Due to its range from [-128,127].
I use Pytorch to reproduce your project. However, my model's accuracy on val data is under 70%. If we directly use 8-dimensional sequence data, will the features be too singular? Here is my code, could you do me a favor to improve that val_result?
The text was updated successfully, but these errors were encountered: