How can I do 1D convolution on a 880*1 feature with filter size 45*1 with stride of 42?
3 ビュー (過去 30 日間)
古いコメントを表示
I have a 885*1 feature and I would like to do a convolution with 45*1 with stride 42.
I want to get a 21*1 feature as a result.
If input layer(885*1) is named A, what sholud be the code?
0 件のコメント
回答 (1 件)
Matt J
2020 年 7 月 19 日
編集済み: Matt J
2020 年 7 月 19 日
You can create a weight matrix that computes the convolution using func2mat on the File Exchange
For example,
>> k=rand(45,1);
>> C=func2mat(@(z) conv(z,k,'valid'),rand(885,1));
>> C=C(1:42:end,:);
>> whos C
Name Size Bytes Class Attributes
C 21x885 22208 double sparse
If you wish, you can verify that C*x gives the equivalent convolution as follows,
>> x=rand(885,1);
>> y1=conv(x,k,'valid'); y1=y1(1:42:end);
>> y2=C*x;
>> norm(y1-y2)
ans =
1.2809e-14
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Filter Analysis についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!