whether is imageInputLayer flattened?

조회 수: 1 (최근 30일)
Shuwei Wang
Shuwei Wang 2024년 9월 11일
편집: Matt J 2024년 9월 11일
I am reading document about imageinputlayer for digits dataset. I find inputsize layer and then can be followed by a fully connected layer. I am confused here. Whether does it mean that inputlayer is flatten automatically how do i know this information since it is not written in document? could you let me know how it works for the inputsize layer?

채택된 답변

Matt J
Matt J 2024년 9월 11일
편집: Matt J 2024년 9월 11일
No, an imageInputLayer does not reshape the input that it receives, as demonstrated in the following,
net=dlnetwork(imageInputLayer([3,4,2]));
out = net.predict(rand(3,4,2))
out = 3x4x2 single array
out(:,:,1) = 0.2145 0.9789 0.6522 0.1829 0.1731 0.9383 0.7773 0.6584 0.1303 0.3399 0.2938 0.7219 out(:,:,2) = 0.2146 0.5021 0.7534 0.5433 0.1258 0.8415 0.3084 0.5208 0.8195 0.3574 0.6682 0.9907
A fullyConnectedLayer does keep its Weights in flattened form, as shown below. That may or may not mean that it flattens the input it receives when it comes time to apply the weights. It doesn't really matter, though. The point is, you are not responsible for doing any reshaping/flattening. That is taken care of internally by the layer when its predict() method is called..
net=dlnetwork([imageInputLayer([3,4,2]), fullyConnectedLayer(6)], dlarray(out,"SSC"));
size(net.Layers(2).Weights)
ans = 1x2
6 24
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
net.predict(rand(3,4,2))
ans = 1x6
-0.5368 0.5171 0.5833 0.9237 -0.0548 0.3494
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by