Matrix dimension conversion for image input layer
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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,
0 comentarios
Respuestas (1)
KALYAN ACHARJYA
el 30 de Mayo de 2021
Editada: KALYAN ACHARJYA
el 30 de Mayo de 2021
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 comentarios
KALYAN ACHARJYA
el 30 de Mayo de 2021
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?
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!