Matrix dimension conversion for image input layer

7 ビュー (過去 30 日間)
Basu Sau
Basu Sau 2021 年 5 月 30 日
コメント済み: KALYAN ACHARJYA 2021 年 5 月 30 日
Hi
I have been working on a machine learning task where I have stuck at a point where I need to manage size of matrices for next computations. I am quite unsure how to do it or is it possible to do it..
Currently, I have a matrix, A of size 1000 x 768. I am going to fed this data as an input to the image input layer to train a network. I found that image input layert accepts input in the dimension of [x y z].
I would like to convert the data of A to [1 21 768] size. Is it possible to do such reshaping?
I have tried one of the way like this:
[a,b]=size(A)
newA=reshape(A.', 1,1,a,b)
But it turns out that the data was converted to 1 x 1 x 768 format which I am not looking for.
What should be the ideal solution of this?
thanks,

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 5 月 30 日
編集済み: KALYAN ACHARJYA 2021 年 5 月 30 日
Sir, you can convert the size of the image from 2D to 3D using the following way (The image isualization is not affected)
ori_image=imread('file_name'); %Original Gray Image
image_modied=cat(3,ori_image,ori_image,ori_image); % Image with rxcxslices
"Currently, I have a matrix, A of size 1000 x 768. I am going to fed this data as an input to the image input layer to train a network. I found that image input layert accepts input in the dimension of [x y z]."
%A in [x,y] format
modified_data=cat(3,A,A,A); % [x,y,z] format
  2 件のコメント
Basu Sau
Basu Sau 2021 年 5 月 30 日
Hi Kalyan
Thanks for your help. I have tried your suggestion and it reutrns 1000 x 768 x 3 size of matrix. But I have tried to manage the matrix A to 1 x 21 x 768 size. Is it possible or my idea needs to be reshaped?
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 5 月 30 日
If you want to change 1000 x 768 to 1 x 21 x 768 using reshape, here number of the elements must be same? Are the input features remain invariaent after the operation?
Have you checked on pen and paper?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by