Question for example: Train Classification Network to Classify Object in 3-D Point Cloud, how to evaluate data?
10 views (last 30 days)
Show older comments
Hello,
I am new to using neural networks and have a question about a tutorial "https://de.mathworks.com/help/vision/ug/train-classification-network-to-classify-object-in-3-d-point-cloud.html#TrainNetwork3DPointCloudDataExample-2".
I have been working through this example and would like to know how I can evaluate data with a test set well after the network has been trained?
I know I can use the command "predict(net,data)" or "classify(net,data)" but the data in this tutorial is stored in fileDatastores. But what about if I want to evaluate the network with a single test file, i.e. a pointCloud, from the workspace? Because then, as far as I know, I can't use fileDatastore because fileDatastore asks for a saved file on disk?
Thanks for your help
0 Comments
Answers (1)
Sai Pavan
on 5 Oct 2023
Hi Kr,
I understand that you are trying to evaluate a trained model on a single test file loaded into the base workspace.
If you want to evaluate a trained network with a single test point cloud from the workspace in MATLAB, you can create a custom datastore using the “matlab.io.datastore.MiniBatchable” class. This allows you to load the point cloud data directly from the workspace and feed it into the network for evaluation.
Please refer to the below code snippet to learn how to create a custom datastore and evaluate the network with a single point cloud:
customDatastore = matlab.io.Datastore(@() testPointCloud, 'ReadFcn', @identityFcn); % Create a custom datastore
function data = identityFcn()
data = evalin('base', 'testPointCloud'); % Define the identity function to return the point cloud
end
customDatastore.MiniBatchSize = 1; % Set the 'MiniBatchSize' property to 1 to process one point cloud at a time
while hasdata(customDatastore) % Loop over the point clouds in the custom datastore and evaluate the network
pointCloud = read(customDatastore); % Read the next point cloud from the custom datastore
predictedLabels = classify(net, pointCloud); % Evaluate the network on the point cloud
end
Please refer to the below documentation to learn more about the “matlab.io.datastore.Minibatchable” class and understand the workflow with an example:
Hope it helps.
Regards,
Sai Pavan
0 Comments
See Also
Categories
Find more on Parallel and Cloud in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!