Does patternnet support single precision data?
5 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2021-12-29
回答: MathWorks Support Team
2022-1-20
I created a classic neural network using "patternnet". My GPU is optimized for single precision data, so how can I train the neural network using single precision data?
采纳的回答
MathWorks Support Team
2021-12-29
Unfortunately, single precision data is unsupported for "patternnet".
We advise you to use the new deep learning interface, which uses single precision by default. Please see below for code that creates a deep neural network with similar architecture to "patternnet" using the "iris" dataset in MATLAB:
[x,t] = iris_dataset;\nrng(0)\n[~, nData] = size(x);\n\n% Randomizing the data\nrandIDs = randperm(nData);\nXAllData = x(:,randIDs);\n\n% Data split for training and testing \nY = categorical(vec2ind(t)');\nXTrain = XAllData(:,1:100)';\nYTrain = Y(randIDs(1:100));\nXTest = XAllData(:,101:150)';\nYTest = Y(randIDs(101:150));\n\n% Defining the shallow neural network layers \nlayers = [featureInputLayer(4, "Name", "Input", "Normalization", "rescale-symmetric");...\n fullyConnectedLayer(10, "Name", "firstHidden");\n tanhLayer("Name","tanHyperbolicLayer");\n fullyConnectedLayer(3, "Name", "OutputFC")\n softmaxLayer\n classificationLayer("Name","Output")];\n\n% Setting up training options\noptions = trainingOptions('sgdm', ...\n 'InitialLearnRate',1e-2, ...\n 'MaxEpochs',500,...\n 'Verbose',false, ...\n "Shuffle","every-epoch", ...\n "Plots","training-progress", ...\n "ValidationData",{XTest,YTest});\n\n% Train the network\nnetDLT = trainNetwork(XTrain,YTrain,layers,options);
For more information about the available layers in the Deep Learning Toolbox, you may refer to the following documentation links:
For more information about the "trainingOptions" and "trainNetwork" functions used in the above code, you may refer to the following documentation links:
To learn more about the new deep learning interface, you may refer to the following example:
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!