tiny-dnn / tiny-dnn

header only, dependency-free deep learning framework in C++14
http://tiny-dnn.readthedocs.io
Other
5.86k stars 1.39k forks source link

1D convolution? #1011

Open Thanh-Binh opened 5 years ago

Thanh-Binh commented 5 years ago

Hi, I am interested in use tiny_dnn for 1D data. Can I set the height to 1 and the width to the length of my 1D-data? Thanks

a28293971 commented 5 years ago

Of cause. in fact,the 1D data is shape3D(length,1,1) at the tiny_dnn.

Thanh-Binh commented 5 years ago

Thanks, let me test it...

Thanh-Binh commented 5 years ago

@a28293971 but how can I set up convolution using 1D data (in my case I want to using tiny-dnn for ECG classification)? Here the length of my data is 187 template void constructNet(N &nn, const std::string rnn_type) { int input_len = 187; nn << tiny_dnn::layers::conv(input_len, 1, 183, 16, 6, padding::valid, true, 1, 1, 1, 1, backend_type) << tanh() << ave_pool(183, 1, 6, 2) // S2, 6@28x28-in, 6@14x14-out << tanh(); }

a28293971 commented 5 years ago

Maybe you should use this overloaded function:

convolutional_layer(size_t in_width, size_t in_height, size_t window_width, size_t window_height, size_t in_channels, size_t out_channels, padding pad_type = padding::valid, bool has_bias = true, size_t w_stride = 1, size_t h_stride = 1, size_t w_dilation = 1, size_t h_dilation = 1, core::backend_t backend_type = core::default_engine())

nn << tiny_dnn::layers::conv(input_len, 1, 183, 1, 16, 6, padding::valid, true, 1, 1, 1, 1, backend_type) << tanh() and,according to my calculation, your output size should be 6@5x5 in conv layer.out=(in-f+2p)/s+1.

Thanh-Binh commented 5 years ago

@a28293971 thanks