Creating vector for parametrizing ANN

1 回表示 (過去 30 日間)
Alessio Pricci
Alessio Pricci 2023 年 8 月 12 日
回答済み: the cyclist 2023 年 8 月 12 日
Dear all,
I am struggling with the following problem; I am trying to parametrize an Artifical Neural Network (ANN) by giving vectors containing the number of neurons for each hidden layer. The idea is to collect all prossible ANN structures in a single matrix.
The idea is to obtain output as in the following example:
Number of hidden layers = 4 (as an example)
Possible architectures -> [2 0 0 0; 2 2 0 0; 2 2 2 0; 2 2 2 2; 4 0 0 0; 4 2 0 0; etc] (with 4,8, 16, 32 and all intermediate combinations)
Is there a simple way to generate such a matrix?
Thanks in advance.

採用された回答

the cyclist
the cyclist 2023 年 8 月 12 日
You should be able to use the fullfact function to do this.
I am not exactly certain about the final result you want, but here is a smaller example (so the output is easier to inspect), with the maximum power of 2 you want, and the number of layers (as parameters you can adjust).
Take a look at see if it gives the result you expect. If not, perhaps you can see how to edit it, or tell us what result you would actually want in this case.
MAX_POW = 2; % 2^MAX_POW neurons per layer
NUM_LAYERS = 3; % Number of layers
% Generate all the combinations
n = 2.^(fullfact(repmat(MAX_POW+1,1,NUM_LAYERS)) - 1);
% Replace the 1's with 0's
n(n==1) = 0
n = 27×3
0 0 0 2 0 0 4 0 0 0 2 0 2 2 0 4 2 0 0 4 0 2 4 0 4 4 0 0 0 2

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by