2.4 How to Interpret Your Model
- Extract learned weights from a model
- Interpret thos weights to weigh them against what one might think they should be
2.4.1 Extracting Meaning from Learned Weights
The linear function example was scalar however the features and the kernel here are both vectors Here we are taking the dot product of the two vectors.
= kernel · features + biasoutput
This basically amounts to a relationship between the kernel and the features, where small learned values are learned to have little impact and and positive relationships increase predicted output and negative relationships decrease predicted output.
2.4.2 Extracting Internal Weights from the Model
Since this model has only one layer we can grab the output layer with the following
Then we get the weights with the
getWeights() since we’re using a dense layer the returned array of weights will always have two elements the kernel and the bias..
We can access the tensor we’re interested in with
We can access the contents of the tensor with a call to the
data() function since its an async function we use the promised value as in the previous post marked as
2.4.3 Caveats to Interpretability
If weights are different in a model for a feature that is included twice they can be switched around so we cannot say very much about this feature. Correlation and causality must also be looked at carefully in order to avoid mistakes when making statements about features relationships to outputs…