dspanah / sensor-based-human-activity-recognition-deepconvlstm-pytorch Goto Github PK
View Code? Open in Web Editor NEWDeepConvLSTM model for sensor-based human activity recognition in Pytorch
License: Other
DeepConvLSTM model for sensor-based human activity recognition in Pytorch
License: Other
Hi,
I want to convert your code to CNN model. I modified the model as:
class HARModel(nn.Module):
def __init__(self, n_hidden=128, n_layers=1, n_filters=64,
n_classes=18, filter_size=3, drop_prob=0.6):
super(HARModel, self).__init__()
self.drop_prob = drop_prob
self.n_layers = n_layers
self.n_hidden = n_hidden
self.n_filters = n_filters
self.n_classes = n_classes
self.filter_size = filter_size
self.conv1 = nn.Conv1d(NB_SENSOR_CHANNELS, n_filters, filter_size)
self.conv2 = nn.Conv1d(n_filters, n_filters, filter_size)
self.conv3 = nn.Conv1d(n_filters, n_filters, filter_size)
self.fc1 = nn.Linear(n_filters*filter_size,n_hidden)
self.fc2 = nn.Linear(n_hidden, n_classes)
self.dropout = nn.Dropout(drop_prob)
def forward(self, x, hidden, batch_size):
x = x.view(-1, NB_SENSOR_CHANNELS, SLIDING_WINDOW_LENGTH)
x = F.relu(F.max_pool1d(self.conv1(x),2))
x = F.relu(F.max_pool1d(self.conv2(x),2))
x = F.relu(F.max_pool1d(self.conv3(x),2))
x = x.contiguous().view(-1, self.n_hidden)
x = self.dropout(x)
x = self.fc1(x)
x = self.fc2(x)
out = x.view(batch_size, -1, self.n_classes)[:,-1,:]
return out, hidden
It gives me the following error after running the code:
size mismatch, m1: [50 x 128], m2: [192 x 128] at C:\w\1\s\tmp_conda_3.7_105232\conda\conda-bld\pytorch_1579085620499\work\aten\src\TH/generic/THTensorMath.cpp:136
Please suggest how I can modify your code for developing CNN model.
I trained to the code 500 times with lr 0.001 and the result is always below
Epoch: 289/500...Train Loss: 0.1521...Val Loss: 0.7511...Val Acc: 0.8145...F1-Score: 0.8155...
Epoch: 348/500... Train Loss: 0.1344... Val Loss: 0.8809... Val Acc: 0.8039... F1-Score: 0.8052...
Epoch: 349/500... Train Loss: 0.1328... Val Loss: 0.7956... Val Acc: 0.8001... F1-Score: 0.7997...
Epoch: 350/500... Train Loss: 0.1355... Val Loss: 0.8102... Val Acc: 0.8029... F1-Score: 0.8047...
Even I did the downsampling, the prediction results were still class 0, and the loss did not decrease. Did you know the reason?
Hey, When will you add PAMAP2 dataset to train, I found some papers that have published the accuracy of your model on the PAMAP2 dataset. How did they get this? Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.