mustafa-sarshar / SmartGait

Gait Phase Estimation using Artificial Intelligence
9 stars 4 forks source link

batch_size issue #1

Closed Arks-Folinic closed 6 months ago

Arks-Folinic commented 6 months ago

hello! when I employ your program, I encountered an error when I ran SmartGait_01_allmodels.py and TrainAndTest.py , the pycharm error goes like this "ValueError: The number of samples 8650 is not divisible by batch size 32." I solve this problem technically, however, by changing the file(training_v1.py) of Keras.Tensorflow . I don't think this is a proper way to handle this. How to change batch_size in your file? Sorry , I am new in python and machine learning . I am just want to employ your code for my study learning application. I would appreciate it if you can help me solve this problem Thank you

mustafa-sarshar commented 6 months ago

Hey man,

thank you for your report. I know this error when the version of the Tensorflow is different than what I used in my project, as well as the version of Python itself. I suggest you first download Anaconda package manager, I used to used mini-conda, and then install all dependencies and check the python version, too. Then it should work.

Arks-Folinic commented 6 months ago

Hello! Question 1 (Batch_Size)(Solved) : I have changed all of my python environment to be consistent with your requirements. txt . And the same batch_size problem still occurs "The number of samples 8650 is not divisible by batch size 32" However, when I comment out one strategy-choosing sentence( strategy = tensorflow.distribute.MirroredStrategy() # set to MirroredStrategy). It goes smoothly. In your " 04TrainAndTest.py "(line 64 ) //////////////////////////////////////////////////////////////////////////////////////////////////////// # ## In[] Build the LSTM model_

Set the strategy to train the Model

if tensorflow.config.list_physical_devices("GPU"): strategy = tensorflow.distribute.MirroredStrategy() # set to MirroredStrategy print("Strategy is set to MirroredStrategy") else: strategy = tensorflow.distribute.get_strategy() # set to the default strategy print("Strategy is set to DefaultDistributionStrategy") ////////////////////////////////////////////////////////////////////////////////////////////////////// My laptop is i7-12700H with RTX3060 , it defaults to use tensorflow.distribute.MirroredStrategy() , I commented it out. I use tensorflow.distribute. et_strategy() , the same problem doesn't occur again. By the way , I also add one sentence (tensorflow.compat.v1.disable_eager_execution()) at the top of your code to avoid this following error /////////////////////////////////////////////////////////////////////////////////////////////// tensorflow.python.framework.errors_impl.UnknownError: Fail to find the dnn implementation. [[{{node CudnnRNN}}]] [[sequential/lstm/PartitionedCall]] [Op:__inference_train_function_14672]

Function call stack: train_function -> train_function -> train_function /////////////////////////////////////////////////////////////////////////////////////////////// So far, the code can run normally without errors.

Question 2 (Practical application issues) : I am wondering if this model can detect three gait stages in real-time (i.e. FO MidS FC). I am an undergraduate student working on a competition topic in the field of AI. I would like to know if it is possible for this program to receive real-time data from my inertial sensor, so that it can determine the gait stage at this time in real time. That is to say, can the trained model be applied to real-time gait stage judgment?

I would greatly appreciate it if you could answer my question Thank you!

mustafa-sarshar commented 6 months ago

Hello Again,

because of your question, I tested everything again on my Linux machine. Everything worked well and I got no errors. As I told you before, you must pay attention to the dependencies and their exact versions, and more importantly, as I have already mentioned in the README.md file, the Python version must be and MUST BE 3.9.6 in order to be able to run the code. Each version of Python will require different versions of packages, especially different version of TensorFlow, and as a result the code my not work.

And to answer your other question, YES, this model can help your detect Gait phases, please read the article first and learn more about it. But for real time use, you may need to decrease the size of the model and make lighter, and more importantly train it with more data.

Good Luck