Email: [email protected]

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Regarding using trainnet, testnet in binary image classification(size difference between network output and test data output)

Regarding using trainnet, testnet in binary image classification(size difference between network output and test data output)

PuTI / 2025-05-19
Regarding using trainnet, testnet in binary image classification(size difference between network output and test data output)
Matlab News

Hello, every MATLAB users,

I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not

input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False

Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];

It’s simple CNN structure

I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)

I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.

How can I fix this code??

I hope anyone could respond my question.

Thank you for reading.Hello, every MATLAB users,

I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not

input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False

Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];

It’s simple CNN structure

I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)

I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.

How can I fix this code??

I hope anyone could respond my question.

Thank you for reading. Hello, every MATLAB users,

I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not

input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False

Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];

It’s simple CNN structure

I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)

I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.

How can I fix this code??

I hope anyone could respond my question.

Thank you for reading. binaryclassification, cnn, trainnet, deeplearning, testnet MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Clean and automate indents in scripts an live scripts
2025-06-19

Clean and automate indents in scripts an live scripts

Varying device latency for ASIO Device
2025-06-19

Varying device latency for ASIO Device

COnnecting points on opposite end of mask
2025-06-19

COnnecting points on opposite end of mask

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: [email protected]
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term