原算例见
actor
从agent中提取actor信息
actor = getActor(agent)
得到如下内容:
>> actor = getActor(agent)
actor =
rlDeterministicActorRepresentation with properties:ActionInfo: [1×1 rl.util.rlNumericSpec]
ObservationInfo: [1×1 rl.util.rlNumericSpec]
Options: [1×1 rl.option.rlRepresentationOptions]
从actor中提取学习到的参数
params = getLearnableParameters(actor)
得到如下结果
>> params = getLearnableParameters(actor)
params =
1×4 cell array
{3×3 single} {3×1 single} {1×3 single} {[1.8352]}
那么上述数据究竟是何含义?
从actor中提取actor网络
actorNet=getModel(actor)
得到如下内容:
>> actorNet=getModel(actor)
actorNet =
DAGNetwork with properties:Layers: [5×1 nnet.cnn.layer.Layer]
Connections: [4×2 table]
InputNames: {'State'}
OutputNames: {'RepresentationLoss'}
在criticNet中终于看到了Layers信息和Connections信息,如下所示:
>> actorNet.Layers
ans =
5×1 Layer array with layers:1 'State' Feature Input 3 features
2 'actorFC' Fully Connected 3 fully connected layer
3 'actorTanh' Tanh Hyperbolic tangent
4 'Action' Fully Connected 1 fully connected layer
5 'RepresentationLoss' Regression Output mean-squared-error
>> actorNet.Connections
ans =
4×2 table
Source Destination
_____________ ______________________
{'State' } {'actorFC' }
{'actorFC' } {'actorTanh' }
{'actorTanh'} {'Action' }
{'Action' } {'RepresentationLoss'}
上述信息不直观,在 deepNetworkDesigner中打开如下所示:
deepNetworkDesigner(actorNet)
在这张图上终于看到了全景。
根据右侧的Propeties可以清楚看到params与网络的对应关系,如下所示:
可以得到:
params{1}为actorFC的W;
params{2}为actorFC的b;
params{3}为Action的W;
params{4}为Action的b;
critic
从agent中提取critic信息
critic = getCritic(agent)
得到如下内容:
>> critic = getCritic(agent)
critic =
rlQValueRepresentation with properties:ActionInfo: [1×1 rl.util.rlNumericSpec]
ObservationInfo: [1×1 rl.util.rlNumericSpec]
Options: [1×1 rl.option.rlRepresentationOptions]
从critic中提取学习到的参数
params = getLearnableParameters(critic)
得到如下结果
>> params = getLearnableParameters(critic)
params =
1×8 cell array
Columns 1 through 2
{50×3 single} {50×1 single}
Columns 3 through 4
{25×50 single} {25×1 single}
Columns 5 through 6
{25×1 single} {25×1 single}
Columns 7 through 8
{1×25 single} {[0.0879]}
那么上述数据究竟是何含义?
从critic中提取critic网络
criticNet = getModel(critic)
得到如下内容:
>> criticNet = getModel(critic)
criticNet =
DAGNetwork with properties:Layers: [10×1 nnet.cnn.layer.Layer]
Connections: [9×2 table]
InputNames: {'State' 'Action'}
OutputNames: {'RepresentationLoss'}
在criticNet中终于看到了Layers信息和Connections信息,如下所示:
>> criticNet.Layers
ans =
10×1 Layer array with layers:1 'State' Feature Input 3 features
2 'CriticStateFC1' Fully Connected 50 fully connected layer
3 'CriticRelu1' ReLU ReLU
4 'CriticStateFC2' Fully Connected 25 fully connected layer
5 'Action' Feature Input 1 features
6 'CriticActionFC1' Fully Connected 25 fully connected layer
7 'add' Addition Element-wise addition of 2 inputs
8 'CriticCommonRelu' ReLU ReLU
9 'CriticOutput' Fully Connected 1 fully connected layer
10 'RepresentationLoss' Regression Output mean-squared-error
>> criticNet.Connections
ans =
9×2 table
Source Destination
____________________ ______________________
{'State' } {'CriticStateFC1' }
{'CriticStateFC1' } {'CriticRelu1' }
{'CriticRelu1' } {'CriticStateFC2' }
{'CriticStateFC2' } {'add/in1' }
{'Action' } {'CriticActionFC1' }
{'CriticActionFC1' } {'add/in2' }
{'add' } {'CriticCommonRelu' }
{'CriticCommonRelu'} {'CriticOutput' }
{'CriticOutput' } {'RepresentationLoss'}
上述信息不直观,在 deepNetworkDesigner中打开如下所示:
deepNetworkDesigner(criticNet)
在这张图上终于看到了全景。
根据右侧的Propeties可以清楚看到params与网络的对应关系,如下所示:
可以得到:
params{1}为CriticStateFC1的W;
params{2}为CriticStateFC1的b;
params{3}为CriticStateFC2的W;
params{4}为CriticStateFC2的b;
params{5}为CriticActionFC1的W;
params{6}为CriticActionFC1的b;
params{7}为CriticOutput的W;
params{8}为CriticOutput的b;