albertbup / deep-belief-network

A Python implementation of Deep Belief Networks built upon NumPy and TensorFlow with scikit-learn compatibility
MIT License
481 stars 212 forks source link

what is the shape of an accelerometer dataset? #26

Closed deerdodo closed 6 years ago

deerdodo commented 6 years ago

what i want is to modify this code in way to accept my accelerometer dataset, below is the code with my modification to add the new dataset

import numpy as np

np.random.seed(1337)  # for reproducibility
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
from sklearn.metrics.classification import accuracy_score
from dbn import SupervisedDBNClassification

# Loading dataset
train = np.loadtxt("TrainDatasetFinal.txt", delimiter=",")
test = np.loadtxt("testDatasetFinal.txt", delimiter=",")

y_train = train[:,7]
y_test = test[:,7]

train_spec = train[:,6]
test_spec = test[:,6]

# Training
classifier = SupervisedDBNClassification(hidden_layers_structure=[256, 256],
                                         learning_rate_rbm=0.05,
                                         learning_rate=0.1,
                                         n_epochs_rbm=10,
                                         n_iter_backprop=100,
                                         batch_size=32,
                                         activation_function='relu',
                                         dropout_p=0.2)
classifier.fit(train_spec, y_train)

And this is a sample from my dataset

(Patient Number, time in millisecond, accelerometer x-axis,y-axis, z-axis,magnitude, spectrogram,label (0 or 1))

1,15,70,39,-970,947321,596768455815000,0
1,31,70,39,-970,947321,612882670787000,0
1,46,60,49,-960,927601,602179976392000,0
1,62,60,49,-960,927601,808020878060000,0
1,78,50,39,-960,925621,726154800929000,0

in the dataset i am using the only the spectrogram as input feature and the label (0 or 1) as the output the total traing samples is 1,415,684

So how to modify this code to be appropriate the signal dataset instead of the image dataset

albertbup commented 6 years ago

Hi, you just need to pass a matrix data of shape (n_samples, n_cols) and a labels vector of shape (n_samples, ), similar as scikit-learn works.

Regards

deerdodo commented 6 years ago

self.n_visible_units = X.shape[1] how to modify this line of code for my dataset

ayoubbargach commented 6 years ago

Do you have an error like this : AttributeError: 'list' object has no attribute 'shape'

It is weird because np.loadtxt() generate a numpy array