Hear everyone and welcome back to this class advanced convolutional neural networks in this lecture
I'm going to walk you through the code to output the first few letters of resonant.
Hopefully this helps to explain any of the nuances you may have come across in your implementation.
So the first interesting thing we have here is the regulator and the max pool there.
Again I don't normally do this in my code but I did this time to be more consistent with care.
We just need to make sure that they have the same interface as all the other layers which means a forward
function and a get harams function.
Next we have the partial resident class in the constructor.
We define all the layers as expected.
The convolution action form review makeable and then convoke.
Remember you can find all of the shapes from the Khera summary function.
We also define an input placeholder and get the output so that we can use these in the Predict function
later
similar to the other layers we have the copy from Cara's function which just cause the copy from Kerins
function on the sub layers.
We also have the forward function and the predicate function.
Notice how the forward function is nice and simple because of the fact that every layer has the same
interface even if it's just applying the well-you.
Next we have said session and get harams which just recursively sets the session and gets the.
We'll see why these are useful very shortly.
Next we have the main section.
The first thing we need to do is get Cara's version of Reznick since that is our target to create a
partial model.
We just create a new Cara's model instance and set its output to be the output of a resonant layer at
index 16.
Remember that to get this number you just look at the model summary to find where the car block ends.
Alternatively you could just print out resin that dot layers.
Next we create an instance of our own class the partial resonant then we create a fake image and get
the output from the chaos model which is what we're going to compare to.
Now here is the interesting part.
Normally intensive flow you can use TFK global variables initialiser here you cannot.
The reason is Keres is also using tensor flow as a back end.
And so the existing Carrot's resonant weights are also tensor for variables.
So you don't want to initialize them you only want to initialize the parameters of our model.
This is why we needed to define the get harams function on each of our layers.
Next is another very interesting thing you do not want to call T.F. session to make a new session.
This is because in the Karris backend a session has already been made.
So you'll get some pretty strange errors if you try to make your own session once we've set the session
and initialize the session.
We can use the resident to get an output.
Remember that this is still just with random weights.
This is a sanity check to make sure everything goes through without crashing.
The next step is to copy the weights from the Karris layers.
That part is not trivial.
So hopefully you were able to figure it out once we've done that.
We get the output again and then check this out is the same as the Cara's output.