0
$\begingroup$

I want to predict whether a machine will fail based on the most recent set of measurements taken by on-board sensors. I have several dozen machines, each with a sensor that takes a measurement at regular intervals. Some machines have already failed, but most have not. The resulting dataset looks something like the example data below, with one row for each machine, showing the 30 most recent sensor measurements as well as a "failure" designation, where 0 indicates that the machine is still operational, and 1 indicates that the machine failed after the measurement taken at time30.

    ID  time1   time2   time3   time4   time5   time6   time7   time8   time9   time10  time11  time12  time13  time14  time15  time16  time17  time18  time19  time20  time21  time22  time23  time24  time25  time26  time27  time28  time29  time30  failure
0   1   3.085   1.360   2.351   3.858   5.562   3.709   6.423   9.706   5.521   0.045   5.676   6.045   5.540   8.404   2.701   7.969   2.535   5.096   7.949   5.888   9.250   6.608   1.441   2.066   8.885   6.985   1.310   4.245   9.068   3.283   0
1   2   7.938   9.833   5.776   3.218   0.978   4.164   8.079   7.425   5.554   0.259   5.927   5.168   8.751   8.713   5.651   9.342   0.385   6.623   4.348   9.113   9.230   7.134   4.316   4.725   9.258   4.248   6.497   7.354   7.707   2.527   0
2   3   5.946   0.096   1.972   6.362   9.990   6.702   9.683   5.111   2.273   7.581   0.379   5.571   0.274   9.429   3.572   2.032   0.543   0.467   3.028   1.095   0.529   8.780   4.375   7.544   0.754   5.400   4.943   1.821   1.486   2.492   1
3   4   6.793   9.299   1.522   9.307   0.438   9.999   0.481   6.420   3.881   4.933   7.185   4.176   4.224   7.403   9.101   3.300   3.273   0.556   6.421   5.528   9.262   6.160   1.573   9.299   4.307   0.808   4.270   6.886   3.548   4.889   0
4   5   8.470   5.503   7.420   8.363   3.316   1.047   9.695   3.884   2.010   8.353   1.308   7.733   7.898   3.327   2.737   2.858   2.002   5.483   7.750   4.952   2.435   5.980   6.403   0.985   1.591   8.886   7.586   0.062   6.002   1.144   1

My Question:

What shape should my input tensors take? Should my input tensor have the shape of (num_of_samples, 1, 30), or (num_of_samples, 30, 1), where the 30 is the number of time point measurements per sample? Which dimension of the tensor represents the number of features, and which represents the number of time point measurements? I've made a related post here that is more code-focused and has additional specifics about the structure of my CNN using PyTorch.

$\endgroup$

1 Answer 1

1
$\begingroup$

I've seen your similar question on Data Science stack exchange and held off answering because I work with Keras/Tensorflow rather than PyTorch. As that question hasn't been answered, I'll answer for how this works in Keras. Hopefully this will be some help, if you don't get a specific answer for PyTorch.

The time series features are often called channels in neural network terminology. In Keras, by default the channels go last so your input shape should be (num_of_samples, 30, 1), however when creating Conv1D layer this is controlled by the parameter data_format. The default value is "channels_last", but if you want/need to use the shape (num_of_samples, 1, 30), you can set the data_format to "channels_first".

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.