I get an object of class type Autoencoder
after running the specified function:
[X,T] = wine_dataset;
hiddenSize = 25;
autoenc1 = trainAutoencoder(X,hiddenSize,...
'L2WeightRegularization',0,...
'SparsityRegularization',0,...
'SparsityProportion',1,...
'DecoderTransferFunction','purelin');
If I try to query one of the properties, I can get it without problem,
>> autoenc1.EncoderWeights(1,1)
ans = -0.0404
However, if I try to set it, I get an error:
>> autoenc1.EncoderWeights(1,1) = 0.4
In class 'Autoencoder', no set method is defined for Dependent property 'EncoderWeights'. A
Dependent property needs a set method to assign its value.
Why are you getting this problem?
To understand this behaviour we should take a look inside the
Autoencoder
class (\MATLAB\R20###\toolbox\nnet\nnet\nnnetwork\Autoencoder.m
). We can see the following:'EncoderWeights'
is defined inside aproperties(SetAccess = private, Dependent)
block.function val = get.EncoderWeights(this)
.Thus, we see that
'EncoderWeights'
is neither a publicly settable field, nor is there a public setter method for it - so it's not surprising you're getting an error. BTW, on R2018b the error might be a bit more informative:(If you are unfamiliar with the concepts I used above, I suggest you read about classes in MATLAB.)
How to solve it?
You can use the
network()
method of youAutoencoder
object to get anetwork
object, then customize it as you please. In your case you would assign the new weight(s) intonet.IW{1}
. Afterwards you cantrain
,sim
etc.