Does patternnet support single precision data?

8 ビュー (過去 30 日間)
MathWorks Support Team
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
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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by