Comments (1)
It seems like the issue is related to the input dimensions of the RNN model during training and testing. In your train method, you are reshaping the input features to have the shape (batch_size, 1, num_features) before training the RNN model. However, during the prediction phase in the predict method of the ClassifierOnlineTest class, you are reshaping the features to have the shape (1, 1, -1).
To resolve this issue, make sure that the input dimensions during training and testing are consistent. In the train method, you are reshaping the input features using PCA, and in the _init_rnn_model method, you set input_shape=(None, NUM_FEATURES_FROM_PCA) for the first LSTM layer. Therefore, the correct input shape for the RNN model during training is (batch_size, timesteps, features).
Here's a suggested modification to your code:
Update the train method in the ClassifierOfflineTrain class to reshape the input features to have the shape (batch_size, window_size, num_features):
def train(self, X, Y):
n_components = min(NUM_FEATURES_FROM_PCA, X.shape[1])
self.pca = PCA(n_components=n_components, whiten=True)
self.pca.fit(X)
print("Sum eig values:", np.sum(self.pca.explained_variance_ratio_))
X_new = self.pca.transform(X)
# Reshape input features to match the RNN input shape
X_new = X_new.reshape(X_new.shape[0], self._window_size, X_new.shape[1])
print("After PCA, X.shape = ", X_new.shape)
self.clf.fit(X_new, Y, epochs=100)
Update the predict method in the ClassifierOnlineTest class to reshape the input features consistently:
def predict(self, skeleton):
# ... (existing code)
if is_features_good:
features = features.reshape(1, self._window_size, -1)
print(f"Shape of input features: {np.array(features).shape}")
curr_scores = np.argmax(self.model.predict(features), axis=-1)
self.scores = self.smooth_scores(curr_scores)
# ... (existing code)
By ensuring consistent reshaping of input features, you should be able to resolve the dimension mismatch issue during prediction. Does that help?
from realtime-action-recognition.
Related Issues (20)
- Increase number of person dectected HOT 1
- How to use [lying, other, sitting, standing]
- ModuleNotFoundError: No module named 'sklearn.neighbors.classification' HOT 8
- 大佬您好,想问一下您的数据集怎么标定的吗?如何生成valid_images.txt文件呢 HOT 1
- 行为识别用的什么方法呀 HOT 1
- training is slow !! HOT 2
- how to remove the head joints HOT 1
- ModuleNotFoundError: No module named 'tf_pose' HOT 3
- 您好!可以请教一下是否有相关文章或者资料对这个项目的介绍分析吗 HOT 7
- 不好意思,请问在运作前都会显示这些东西而延迟一段时间,请问这个要怎去掉呢?
- Normalization performed twice
- Is it possible to use LSTM models using this feature preprocessing and extraction method?
- number of features
- AttributeError: module 'tensorflow_core.contrib' has no attribute 'tensorrt'
- how to generate valid_images.txt. HOT 2
- 当我测试摄像头的时候,CV2
- warnings.warn("Invalid fps of video: {}".format(video_path))
- AttributeError: module 'tensorflow' has no attribute 'nn' HOT 1
- can i use ucf101dataset to train more labels?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realtime-action-recognition.