That defines what the valid solutions even look like. So in the simplest case, if this is a classification problem, right?


Implicit MLE: Backpropagating Through Discrete Exponential Family Distributions (Paper Explained)

This is a classification problem. Theta would sort of.


Yeah, you can think of this as a classification problem and then Z would be selecting the class, right?


You can model theta in this case as just a vector of ones. And then Z right here could select the class by simply putting that entry to one.


Wherever, of whatever class is selected. And the constraint set C could be easily modeled by saying the norm.


What is that? The sum of all the entries, which is probably the one norm of Z must be equal to one.


That could be the constraint set. Am I correct here?


I'm not sure I can actually model. I probably can't model it like this. Like here, there probably needs to be like,


there probably needs to be some sort of cost per class or something like here. And then I can model the constraint as saying the inner product of Z with a vector of ones.


Must be equal to one. That looks better. So that is actually part of the definition of the constraint set.


And the problem in these cases is that this constraint set makes it very difficult on obtaining good gradients through this discrete problem.


Because right here, as you can see, it's not really easy because most of the Z vectors in the Dijkstra problem aren't actually valid paths.


So the issue here is that we need a gradient. We need to respect the constraint set of the problem.


They go ahead and they formulate this, as I said, as this problem where you have this vector Z is whatever solution you propose.


The theta is the definition of the problem. The inner product is sort of the reward, let's say, the reward, maybe the inverse loss of the problem.


And they can now formulate this as a exponential family distribution by simply raising this, by putting this inside of an exponential function.


Let's see if they've done it somewhere right here. Look at that. Oh, it's not even a minus sign.


All right. So for now, just trust them that it is necessary to formulate it as a distribution and don't just kind of hang in there.


It is going to get very complicated, but it is going to lead somewhere.


So they can formulate this inner process as a probability distribution, P of Z, that is according to the exponential family.


So as I said, the exponential family here, you put in this thing right here. There is a temperature at which you sample.


So what is that essentially is going to do is going to normalize, given this right here.


This is the log partition function, the normalization constant.


This is essentially going to give you a distribution over the individual dimensions of the Z vector.


And that is going to be normalized and is going to be more peaky or less peaky depending on the temperature right here.


So the process that they formulate this as is you take some input X right here.


You put it through the first neural network to obtain the theta.


The theta is essentially the problem definition for the inner algorithm.


The inner algorithm you formulate as a probability distribution.


So it's going to have more or less likely states with the more likely states being the ones that solve the inner optimization problem.


More perfectly to more reward.


So Z is going to be a random variable that is according to that distribution.


For now, you can just think of Z as a random variable.


And the likely states of Z are the ones that have the paths that have a very short path through the in our example.


Or whatever states solve the inner problem very accurately.


And then from that Z we're going to put that through another neural network that's going to give us our output.


And we're going to compare the output with the gold label.


And then we're going to back propagate through all of it.


Our parameters are the parameters here and here.


So the parameters of the two neural networks F U right here.


This is easy to do right because we can simply back propagate from Y into the neural network.


And the parameters of H V, the V parameters.


This is hard. This is the hard part.


So what do we need to do in order to back propagate all the way to H sorry to the V variables.


Well what we need to do is we need to the direction here is that the parameters sorry X becomes theta becomes Z becomes Y.


This is with the help of the parameters V and this is the help of the parameters U.


U is easy. For V what we need to do if we want to have the what you can see right here the gradient with respect to V.


We first need the gradient with respect to theta and then we can once we have the gradient with respect to theta.


Where is it? Where is it?


I guess here. Once we have the parameters with respect to theta we can use the back propagation algorithm again to back propagate into this network and change the weights V.


So how do we get the gradients with respect to theta.


Again this is means we have to back propagate through this piece right here which is the inner optimization algorithm.


So here is it appears the chain rule expanded. This is this here that's theta.


So we need the parameters the gradient with respect to theta and then we can use back prop.


OK. This by the way is the entire algorithm as it's going to be later.


You can see it's fairly simple.


You can also see there is a lot mistake right here but I think that's my conversion.


So what they do is they say this it's very hard.


It's very very hard to compute this gradient with respect to this inner optimization procedure right.


It's very hard to compute a gradient with respect to the Dijkstra shortest path algorithm.


Essentially you'd have to know how do I need to change my graph definition in order for the path to become shorter or different in some way.


And that's very hard. Like all you can do really is kind of try and see what happens.


I wouldn't know anywhere anyhow else because yeah remember that what the theta is.


The theta is the output of the first neural network.


So the theta is the definition of the graph and that is produced by by this neural network right here that looks at the picture and gives you the discrete graph.


So essentially what it gives you is an adjacency and an adjacency matrix.


But still so the question is you know how does my adjacency matrix need to change for the Dijkstra algorithm to find a shorter path.


Let's say a shorter path or well or a path that is more close to the gold label that I have because you don't always want to shorter you actually want to learn from data.


So the first step they do in this challenge in this sub challenge right here is they say this is too hard.


We're going to replace the loss right here this loss the true loss of our output compared to the label with a surrogate loss.


This L is an implicitly defined maximum likelihood objective and we're going to calculate its gradient instead of the gradient of our true loss.


Now the logic of how we get there is the following.


In this inner problem we define a probability distribution this probability distribution.


Remember what is this P here P describes the solution space of in our case the Dijkstra algorithm.


So P is a distribution that would assign high value to or high likelihood to paths that are very short in the graph that's defined by theta and low value to pass that are very long in this same graph.


Now what we can say is can we this is essentially a distribution can we find a different distribution we call a target distribution where we can show that in expectation the loss the loss from this target distribution right here is always smaller than the loss from the true distribution.


So essentially can we find a distribution that where the paths that it outputs are lower in loss lower in the final loss than the ones we have.


So remember we have X and all of that and the end there is Y right.


We predict Y and we compare the Y to the true Y.


There's going to be some loss and the question is can we reduce that loss right here.


So we don't necessarily want to find theta such that we find a shorter path.


But we want to find a more appropriate theta in here such that the rest of the neural network can predict Y hat more accurately in order to be closer to Y.


For in the in our example we want to if if our neural network right here is very bad at actually extracting a proper walkable graph from the landscape right here.


Like if it doesn't recognize that this is a lake you know it thinks you had all of this is really fine to walk on and so on the graph right here will be quite crappy the weights on the edges will be not accurate right.


It's not inferred correctly from the landscape.


That means that this network here will have a pretty hard time determining the actual value of the shortest path because even though the Dijkstra algorithm does a good job of finding the shortest path.


It's on the wrong graph and therefore it's useless.


So what we need to be able to do is we need to be able to more accurately extract the graph from the image.


So we need to train these parameters right here.


So here we ask ourselves can we come up this distribution P here.


That's the distribution of solutions to the problem that's defined by theta.


We ask ourselves can we come up with a distribution that has a lower loss than the distribution we have.


And the answer is going to be yes we can do so with a simple a simple let's say trick.


So if you look at back at this I realize we're in like three layers deep of problems like we have a problem for that we have another problem to solve for that we have another problem to solve.


Our current problem is that we want to see can can we change this distribution such that the loss is lower.


How do we need to change this distribution essentially.


And the answer is going to be we're going to take the output right here and we're going to pass it through this network.


We're going to look at the loss and we're going to back propagate that loss until the point where this algorithm stops.


And then we're going to take one gradient step into the direction right here and then that is going to be our new distribution.


So what does that mean in our example right here.


We're going to take the graph that we output right here we're going to run it through Dijkstra gives us the shortest path.


Remember this is a crappy graph because our network initially is not good.


We're going to put that through this neural network right here that determines the cost and we're going to calculate the loss and back propagate that.


So what does that give us ultimately that tells us well the gradient says what how do I need to change the output right here in order for the neural network that follows to do a better job.


And let's say the output is well this edge here has a bad weight or in fact this edge there's an edge right here that's missing or or something like this.


No sorry no that is formulated wrongly.


What we are going to change is we're going to change obviously the Z which is the solution so it's going to say in this shortest path that you computed there's something wrong.


For example you should have maybe taken a different shortest path or you should have weighed it differently or something like this.


And we're going to take a step into that direction.


So for example if the shortest path rather than up and over should have gone directly we know that the edge right here should have had maybe a lower cost associated with it or something like this.


So we're going to use gradient descent to see how do we need to change the inner problem such that the rest of the pipeline does a better job.


And that's what you see. That's what you see right here somewhere.


There. OK. So this is the target distribution is this right here.


So it's the same as the regular distribution of inner solutions however instead of inputting the graph as it is we're going to input the graph minus a step size times the gradient of the loss with respect to the output of the inner of with respect to the output of the inner solver.


So this is using gradient descent in order to come up with a better problem definition right here.


Since these two are vectors they're multiplied together we can use in fact the gradient with respect to Z and subtract that from theta because they're of the same dimension.


So we're going to ask ourselves what would be what would be a more appropriate problem definition in order for the rest of the network to do a better job.


And that's going to be our so-called target distribution.


And now our job now we have a pretty simple job. Our job is going to be well can we make it such that the current the current graph that we output right here is more like this target graph.


So can we make the distribution P more like the distribution Q is the same as asking can we make the current graph that was output by the network H more like the graph that would be more optimal for the rest of the network.


And that is let's say a solvable problem. In fact if you work it out the formulas get pretty simple.


So if we do it like this and by the way this inequality here is crucial obviously because and but we see why it's given because of gradient descent we're in expectation guaranteed that the Q distribution is going to have a lower loss than the P distribution because we do one step of gradient descent with respect to the loss.


Right. So essentially we do a step of gradient descent in the inside and then our surrogate loss is going to be well can we make the output distribution more like the result of that gradient descent.


This this must be one of the most confusing videos ever but I hope you're still with us.


So what we want is to make these two distributions closer. Remember we said we can't back propagate through the discrete optimization procedure.


So what do we do. We said instead of back instead of back propagating through the inner optimization procedure we're going to replace that by a new objective.


The new objective has two steps. Step one determine what would be what would be a better output for for the discrete sorry what would be a better input for the discrete solver.


And then step two is can we make the input that we've received more like the input to the discrete solver. This is where this where we do the gradient descent inside.


And how are we going to make distributions more like each other. That's this right here. This is the KL divergence between P the actual distribution and Q the target distribution.


And that's going to be our surrogate loss that we use instead of the loss that we cannot differentiate.


If you if these are both exponential distribute exponential family distributions you'll see that this pretty easily cancels all cancels out and reduces.


And in the end the gradient of this surrogate loss simply going to be the difference between the two marginals.


So between the two means of the distributions. Now this seems pretty easy but inside of the three layers of problem we get another problem.


So what does this mean. This is the mean of the exponential family distribution when given a certain definition problem definition theta prime or theta if you're over over here.


This given that it's a let's say it's a hard problem with these constraints sets and so on.


Calculating the mean of such a distribution is hard. It's in fact probably as hard as as solving the the entire problem itself.


So calculating the mean of these distributions is not an easy task. Sampling from these distributions straightforwardly is also not an easy task.


So what this paper does is it says for under certain conditions what we can do is we can replace the mean with this.


And this is a trick while a trick a method that they call perturb and map by map they mean maximum a posteriori.


So essentially means that for the exponential distributions what we can do is we can approximate the mean using map the most likely state.


And what's the most likely state. For example in this Dijkstra algorithm the most likely state is in fact the shortest path by how we how we define the problem.


Right. So we've defined the problem as the inner product between the problem definition and the proposed solution.


Now what's the most likely proposed solution if likelihood is given by the inner product. Obviously the one that maximizes the inner product which is the one that by construction has the shortest path.


OK. So fairly convoluted but this is something we can actually do. So we cannot calculate the means of these distributions but we can calculate the most likely states.


And it's not so straightforward. In fact it is a better estimate. So they consider I think yes.


So you're computing the marginals is in general a what's that sharp P sharp hard problem scales poorly with dimensionality.


So map states are often used to directly approximate the the means. However it's apparently better if you use this perturb and map this strategy where you estimate the mean not directly as the most likely state but as an expectation sampling from a noise distribution and perturbing the state.


What does that mean. That means that you can get the mean of the distribution. Let's again draw our Dijkstra graph right here.


You can get the mean of this distribution by well by slightly perturbing the problem. So maybe slightly reweighing the edges saying this edge is higher this edge is now lower slightly perturbing a lot of times.


And then every time you calculate the shortest path. So most of the time like this will be the shortest path mode for most of this.


But then every now and then you perturb it so hard that you know this edge now goes up very high in cost.


So then you'd have this as the shortest path right here and so on. But ultimately yeah. So adding all of that up getting the expectations over all the shortest paths in all for a lot of perturbations will give you a good approximation of the mean of that distribution.


The last question is a little bit OK. What noise distribution is appropriate for this. And the answer is going to be the answer is going to be that is going to be a Gumbel noise.


And I think this is this now gets a little bit too deep. But just to mention this right here if in fact there are some properties are given and the specific property that needs to be given for this to be accurate is that you can define the problem always such that such that.


The constraint set is given by a number K where you can see right here exactly K entries in Z have to be one.


If that's obviously not covering all of the problems we've considered but it covers a lot of the problems we've considered.


And even if not you can still apply it as I say as they say it's just not as appropriate but still appropriate enough.


And they also have a way to sample Gumbel distributed random variables.


But I don't think necessarily we need to go into that. You just need to know that the appropriate noise distribution in fact to get a good estimate of the mean is a Gumbel noise Gumbel distribution by the way.


It describes extremal values. So if you want to know the distribution of of the maxima of some phenomenon that will be Gumbel distributed.


And then you have it at the end of the day you would the surrogate gradient would be given by the difference between perturbed maximum sorry the maximum a posteriori solutions of perturbed Theta's right here.


And yeah so this is a few layers deep let's actually look at the entire algorithm.


And you'll see it's not that hard. So what do we do in the forward pass. We take X.


And as I said we get theta. This is a neural network. In our case it takes a picture and it extracts the adjacency matrix which is theta. So it extracts the graph that we're now going to run Dykstra on.


So this data goes into this forward pass right here. What do we do.


In fact we forward propagate the maximum a posteriori state of a perturbed version of theta.


And this here if you remember this here is going to give us the mean that's a wrong mu is going to give us the mean of that distribution that we're looking for.


So it's going to be forward propagated in so that is going to be forward propagated to let's say to the second neural network and that's going to give us Y or at least an estimate of Y.


And then we're going to compare to the real Y. We're going to get the loss and now we're back propagating right.


So back propagating we take the loss. We go back. We go back through this first neural network until we're here and that is where this starts.


So the backward pass that would come in here.


Right. This gradient here.


That's the gradient we get from the chain rule in the backward pass.


We also need this step size lambda right here. OK. So what are we going to do.


We're going to take that gradient and rather than giving it straight to like the straight through estimator or to the chain rule.


We're going to compute an update to the theta to our graph definition right to our adjacency matrix or our our cost cost matrix for the shortest path algorithm essentially saying how do I need to change the problem definition for the Dijkstra algorithm in order to in order for the upstream sorry for the downstream modules to do a better job predicting the correct label.


Why. That's so we're going to compute an updated theta. Then we're going to compute a this surrogate loss right here and the surrogate loss as you've seen right here is going to be the difference between the two max perturbed maximum a posteriori things.


So it's going to be by the results that we've derived. Where was it. Where was it here by these results right here.


Remember this is the gradient. This is directly the gradient of our surrogate loss and the surrogate losses.


Can we make the output of the first neural network closer to something that's more useful.


So the gradient is directly given by the difference between these two things.


So by the difference of marginals which we approximate by the difference of maximum postures.


So this requires us to run Dijkstra once here in the forward pass and then requires it to run Dijkstra again here once on the on this updated graph.


And the difference between the two is going to be the gradient in which we have to update our inputs.


Notice that I've talked I think a bit confusingly.


So here I already said how do we need to update our problem definition.


And you could think that you know we could feed that directly upstream but we can't.


The real gradient we want to feed upstream is right is this thing right here.


Essentially the top thing is how do we need to change our problem definition.


So the downstream neural network can do a better job.


And this right here is that what or sorry how does the upstream network.


So the one that maps X to theta.


How does that need to change its behavior in order to produce a better input to the solver.


Yes that is the least confusing I can say.


And then we return the gradient that gradient that we computed.


And this is our substitute gradient for the gradient that would be.


This is our substitute gradient for the gradient of the true loss with respect to theta.


And since it's a gradient with respect to theta we can continue back propagating through here back probating it into this neural network here and update the weights.


So that is it. The only thing I'm not sure about is if they really returned the Z hat right here.


Like it was my impression that in the forward pass they would actually feed the true the true Z upstream.


But I'm not sure because for example where was it.


Yeah here they rely on Z bar which is Z bar is essentially that's mu.


So not sure exactly. Might have to look at the code exactly but I hope you understand a little bit of what's going on right here.


Yeah. So recap. We have some discrete part in our neural network like a shortest path algorithm or some other combinatorial solver or even sampling from or taking the top k elements from some distribution something like this.


This is not the entire algorithm but this is one layer in the neural network.


The layer really requires a discrete operation to continue.


The question is how can we back propagate through that in order to update the rest of the network specifically these upstream parts right here that are in front of it.


They need a gradient signal from the loss that's all the way over here at the end.


So what do we do. We use this algorithm right here.


We forward propagate. Let's say we forward propagate regularly in the backward pass.


We first compute a better target distribution prop a parameterization of the target distribution.


Which essentially means we are going to construct a better problem definition a better problem definition that would make the downstream life easier.


So making the downstream life easier means that we move into the direction of the gradient of that downstream loss.


We move with a certain step size.


And then we ask ourselves well having this target distribution now can we make our upstream modules such that they provide the solver with something that's actually more close like the target distribution.


And that is exactly the gradient with respect to theta.


And that is going to be computed as a difference between two marginals as we've shown.


And we cannot compute the marginals because these distributions are very complex.


They have these constraint sets and so on.


But what we can do is we can compute most likely states.


That's exactly what these solvers do.


And if we compute the most likely states of these perturbed inputs that is going to be a good approximation a good estimator for the marginals.


And there and then at the end we get the gradient.


There is a substitute gradient that approximates the true gradient with respect to the input.


I just want to highlight how why this is so complicated.


It's because essentially we have no idea how to back propagate through like a Dijkstra's shortest path algorithm.


The question is how do I need to change the input right here such that something based on the output changes in some way.


For that I essentially need to know well if I change the graph a little bit.


Like if I up weigh this edge right here.


How is the shortest path going to change.


And this is not a continuous process.


This is a discrete process right.


It's not going to change for a while until I up this too much and then all of a sudden the shortest path is a different route.


Like it's really discontinuous.


So what we're going to do and that's going to be a problem of selecting the hyper parameters like the lambda and the temperature of the exponential distribution.


Is going to be how exactly like how noisy do I have to make this process to get an actual estimate of how my outputs change.


So essentially what I do is I perturb.


So this adding adding this noise right here.


I change my graph a little bit like this right.


And then sometimes the shortest path is going to change.


If I do this you know a million times then I have a good idea a little bit of how is my shortest path changing with respect to an input change.


So that's essentially what I do.


But the problem is I need to tune the hyper parameters.


If I change too little the shortest path is not going to change at all and I'm going to have no idea you know what how I need to adjust because there's no gradient.


If I change too much the shortest path is just going to fly around wildly changing every time.


And again I have no idea how to change anything in order to go into a specific direction.


So that's the challenge right here and the additional challenge.


I don't want to do it a million times for each forward and backward pass.


Ideally you want to draw one sample and have that sample be a good low variance estimator of what I'm looking for.


Cool.


So I've also like I've left out part of this like entire parts of this paper that you can still look at if you so desire.


But this is the basic idea.


Again you can take this there's code you can take it like inside of a layer.


I think I have it open right here.


It's available.


There's code in torch and in TensorFlow.


They give a little bit of an example of this is not the entire algorithm.


This is a little bit of an example of one part of that algorithm to essentially show this inner routine where you have to come up with good set of problem definition.


So here you see the essentially the let's say the true problem.


This is on the left.


You can walk on the right paths and you cannot walk on the dark squares.


And you can see that if you for example sample the if you don't sample at all if the temperatures are set to zero then this is what you get.


It's it's you can see kind of the shortest path but it's not really good.


Right.


If you up the temperature a little bit and let the algorithm do some exploration on you know using the inner algorithm you can see that over time you get a much better a much clearer picture of what the supposed landscape is is looking like.


So this again this is not the entire thing.


This is just this inner part.


It's an illustration of why you need appropriate amount of noise for that inner part.


You can see that over time as the algorithm infers the essentially the every time it solves the shortest path algorithm it gets a good idea over time of how the landscape looks like.


All right.


I invite you to read the paper.


Check out the code.


Check out the video that was made by the authors themselves.


It's surely linked somewhere.


I'll link it.


It'll give you a fresh perspective.


And with that.


And thank you so much for listening.


I'll see you next time.


Bye bye.


Oh there's experiments.


Well OK.


Well there's experiments.


They're better than other stuff.


Cool.


Excellent.


TUNIT: Rethinking the Truly Unsupervised Image-to-Image Translation (Paper Explained)

Hi there! Today we'll look at rethinking the truly unsupervised image to image translation


by Kyungjoon Baek, Yoonjae Choi, Yongjoon Woo, JaJoon Yoo and Hyunjoon Shim.


So in this paper we'll deal with image to image translation in an unsupervised fashion.


So on a high level they replace the need for domain or really single image label annotations


in image to image translation by training a guiding network that is able to sort of


do a self clustering of the image domain and therefore that guides the image to image translation


instead of the previously needed labels.


I myself don't know too much about image to image translation and style transfer and all


of this stuff. This has always been kind of a mystery to me and we'll try to make as much


sense as possible out of this paper if you're with me. I might not get everything right


but I will give my best of course. As always if you like content like this consider sharing


it out and leaving a like and a comment. I do read the comments so I get a good idea


of what you have to say about it.


Cool, so what we're seeing here is an example of image to image translation of like a sort


of a style transfer. Now what you'll have on the left is a source image. Now the goal


is to translate this source image to a different domain while sort of keeping the features


of the image the same and here is sort of I'm always confused because here it's like


we keep the pose of the cat the same. Okay so we sort of keep the same cat but we want


to change its style which means its breed in this particular case. So on the top you


can see that the domain images are they come in these different groups and in fact it's


not only those four but the entire data set is split into these different groups and among


these different groups you have some sort of a shared style. Now this shared style is


what you would like to transfer to the source image. So if you transfer the style of all


of these cats right here which all seem to be sort of ginger cats to this instance right


here what you'll end up with is a cat. Okay it was ginger before. Might not be the best


example but you sort of get what I mean is that the thing that you transfer is whatever


is common among these domain images. Okay and that's what I guess explains why the pose


of the cat stays the same because it only it is basically taught to keep the image the


same except to transfer whatever is common among the images in the domain class and that's


image to image transfer or translation. Now until this paper at least that's what the


paper claims these image to image translation models they required labels and why is that?


That's because you need to know how to build these domains here at the top to get these


different style vectors out or you actually would need label annotations for each image


for each single image you would need to know which one you need to know which one of the


source corresponds to which one of the target. So they have a graphic right here where they


explain the sort of different the different stages that image to image translation went


through historically. So first you'd have to have corresponding images one to one where


you say okay here is an example of a sketch of a shoe and here is the corresponding shoe


here is the sketch of another shoe and here is the corresponding shoe and so on and from


that you could learn a model that translates from one domain to the other because you have


corresponding image level annotations which image corresponds to which so basically which


element of the domain a corresponds to which element in the domain B then the next stage


of this was when you only need set level annotations and that's sort of what we looked at if you


had supervised labels for domains so what you'll say is that there are three domains


a B and C and actually let's let's forget C for a moment and just deal with A and B


to make it equivalent to the thing on the left now I just know that these things are


instances of class A and these things are instances of class B yet I don't there's no


correspondence right there is no this corresponds to this or or something like this so image


to image translation is now possible between domains when I just have domain level labels


but this is still expensive collecting these labels you know it's is like collecting labels


for a supervised data set a human needs to look at each image and then conclude what


sort of domain it is their paper introduces the following where you do not have domains


anymore you simply have a data set X now this data set your hypothesis is that there are


still going to be domains in the data set they can I guess they can be overlapping or


not but there are still going to be domains you just don't know what they are so in this


case I guess you could differentiate these people into many many different ways but in


essence you're going to assume that there is some kind of a domain structure you just


don't know what it is but if you knew what it was then you could just simply apply methods


from here to the data set and you'd be done now their paper shows that if you apply something


like a self clustering approach and we've seen these approaches before in the paper


about learning to classify images without labels if you have techniques like this you


can do like a self clustering approach on this data set X right here and then you could


learn your image to image translation yet this paper shows that if you do that the quality


is not as good as if you do both things jointly so what this paper does is it jointly learns


to cluster let's say to self label the images and to make the to do this image to image


translation and by doing the tasks jointly they help each other perform better okay that's


the general overview so how do they do this they have three different parts to their model


there is the encoder or they call this the guiding network there is the generator and


there is the discriminator so the generator and the discriminator they are fairly standard


GAN generators and discriminators so general adversarial network but they have like a bit


of some sort of twists so you can already see from the design from the drawings right


here the discriminator is probably the easiest the discriminator gets an image right here


it doesn't have to be a generated it is a either a generated image or a real image and


it needs to decide you can see right here this means that the input domain is a vector


or an image in this case and the output is a number it needs to decide if it's real or


fake now in fact it's not as easy because you can see there are these multiple heads


right here so this whole thing as I said is built on this kind of pseudo clustering approach


there is this pseudo label that comes out of the left side we're going to look at that


in a second but in essence you assume that there are multiple classes multiple domains


in the data set and the discriminator here has one classification head for each of those


classes so from somewhere outside it will get the information oh this is now supposed


to be one of those ginger cats right as opposed to one of those black and white cats or one


of the brown haired cats no it's one of the ginger cats and then there is a special head


on top of the classifier that only classifies fake from real ginger cats okay which is a


different classifier from the other domains so the discriminator it's sort of a conditional


discriminator conditioned on a label okay from the discriminators point of view it's


simply a label conditioned discriminator discriminating between real and false and I think that's


yeah how you train the discriminator is you would give an image and you would let these


encoder here this guiding network label the image and how we come up with this label again


that will look in a second but this just gives a label and then you'd sell you for that particular


label you'd classify the image into real or false now the fact that there is this shared


part right here of course is you could also think of having one discriminator per class


but the shared part it gives you some shared features and so on but it's not necessary


it's not the the point is that there is a discriminator per class it's class conditional


okay so what about the generator I think is I guess is the most complex what about this


this encoding network right here it's E for encoder I guess but they also call it the


guiding network so what this does is this is what's this supposed to do is it'll take


an image any image and it will output two things one is a label and one is a style code


so the label is supposed to be a number between 0 and k minus 1 so that's supposed to be a


class label and how do you know how many classes there are if there are no labels you just


guess and your best bet is to slightly over guess so if you expect there to be between


10 and 15 classes maybe put k to 20 okay you don't want to under guess but you can over


guess but not by too much of course so you have to have this this estimation of how many


classes but then this E it simply comes up with a class label and it also comes up with


the style code now these two things are going to go then different pathways in this in this


network the label is directly going to the discriminator right the generator does not


see the label okay the style code does not go to the discriminator but goes to the generator


all right so the two inputs from the encoder they one goes to the discriminator which is


the label and one goes to the generator which is the style now the generator lastly it takes


a source image and it takes this style code right here now the style code is encapsulating


as we said the style of the reference image so the style is supposed to be whatever whatever


whatever makes this domain of images the same so the style the way we're going to train


this is that the style is going to describe somehow all the images that are from this


label the style is going to describe whatever the style is it's very hard to it's very hard


to explain if we look at the loss it becomes clearer why the things are how they are so


it takes the style code and it takes the source image and it combines them and its task is


to output this generated image as you can see in this example the generated image is


basically this cat but with the style of the reference image and it outputs an image and


the discriminator of course then is tasked with differentiating whether that image is


real or fake for the given label over here okay so this is the entire thing and you all


train this jointly so you jointly train the encoder to produce these class labels and


the styles you train the generator to take in the styles and the source images and output


the generated image to fool the discriminator and the discriminator at the same time is


trained to differentiate between real and fake images based on the label that the encoder


gives very very convoluted and complicated but there are a few things that make it easier


first of all as you can see here the pseudo label is detached is argmaxed and detached


so the pseudo label really is a number and there is no gradient back propagation along


this line okay that makes that makes it a lot easier so the so what we first need is


we need a way to train the encoder to come up with suitable class labels even though


it doesn't get any back propagation signal into that part of its network so that's where


we start with the loss functions the way we're going to do this is we're going to take the


following approach we're going to take an image and we're going to take a randomly augmented


version so for example a random crop or a horizontal flip and so on so the now we bring


in ideas from self-supervision and again if you watch the video on learning to classify


images without labels this is one of their main staples these self-supervised approaches


really tend to learn representations that allow you to self cluster now in that paper


they go further and they do this nearest neighbor thing in this paper they just do sort of the


first step of this self clustering which i guess makes it such that you could potentially


improve this paper by applying the other paper but who knows so we're going to take an image


and we we're going to augment it okay so that means we're going to like random crop it or


in change its luminance or whatnot so we have two versions of the same image and what we


want to maximize we want to maximize the mutual information between not between the images


themselves but p is going to be this output of the encoder so x goes into the encoder


and the encoder outputs the style and the class label and the class label here so p


is going to be the class distribution all right so this is going to be like a histogram


or maybe the log it's it's good or the yeah so it's going to be a histogram over classes


from which we're going to sample the label c or l or whatnot y hat y but the p is the


distribution over output classes so since we don't have a label we can't train the distribution


like in a supervised way supervised way so what we'll have to say is we want to maximize


the mutual information between the output distribution of the image and the output distribution


of the augmented image now that entails the following two quantities there's the entropy


of p and there's the conditional entropy of p given p augmented now first of all it means


we want to maximize this the entropy of p and that's supposed to be over the entire


data set so this is the entropy over the entire data set x what it means is that we want different


x's so if there's x1 x2 x3 and so on we want those to have different distributions in labels


okay so if if the entropy is really high of the distribution p that means that different


images get assigned to different classes some something like this all right if this is low


then that would mean all the images basically get assigned to the same class and that's


not good we want our classifier since we don't have labels it's a it's basically a cluster


we want our cluster to sort of fill the space of possible clusters with the images so that's


the first thing we want to maximize the mutual information we need to maximize this entropy


and then second since this is a minus here we need to minimize the conditional entropy


of p given p augmented what does that mean that means if we know the augmented version


of an image its class labeling should be the same as the un-augmented version so that means


that if I now take one of these x's to x1 augmented or they do a plus augmented right


then that shouldn't really change its class label and this is what these so that should


sort of keep the class labeling this is horrible but the idea here is that it's kind of a reverse


thinking from supervised learning in supervised learning we have the label like this is class


this is class 5 okay this image is class 5 and our thinking is this augmentation techniques


if I random crop an image or if I change its colorization a little bit the class is not


going to change right an airplane with a in front of a blue sky is still an airplane in


front of a bit bluer sky so I assume that it'll still have the same label here I don't


have the label but what I can require is to say whatever you output for the image it should


be the same for the augmented image so these two objectives are enough to give you sort


of a rough clustering of the output space maximize the entropy minimize the conditional


entropy between two versions of the same image okay that's how we train this pseudo labeling


approach so now we have a we have a model that can give a label to each image very cool


so how do we train the other parts now there are additional additional losses here so I'm


not sure yeah we'll go over it so this style part is also has to be trained right this


encoder outputs a labeling we got that covered and it outputs a style part now the style


part if you can see from the graphic it actually goes into let me erase some of that stuff


here the style part actually is down here and it feeds into the generator and luckily


they write detach here and since they don't write to detach anywhere here that means that


we do get gradient back propagation from the generator to the style code so that means


our our encoder here is trained to help the generator with its task of fooling the discriminator


okay but first of all we're going to forget about that for now what we're going to do


is simply look at a loss that they impose on the style that wouldn't they don't have


to impose that loss but they have an additional loss on the style codes for the encoder in


addition to the fact that there is gradient back propagating from G so the second loss


we're going to look at is this style loss the style loss is almost the same so the style


loss loss is a contrastive loss so what you want to do is if you have your data set you


have your data set of images and you you know take images out and you train your network


on and you train then take the next image or you take batches of image you take train


and so on like this right and now you have this image what you want to do for this to


work is you want to build up sort of a queue of images that you have already looked at


like these images these are going and the queue can be let's say 10 long and you would


always throw out the oldest and and in Q and U so when you're done with this image right


here you'll put it into the queue you load your next image and so on so now what does


this mean you now always have a queue of other images and it's not important what they are


as long as they are others right because now we're going to compare ourselves with others


and this is this contrastive loss right here so the style loss is going to be a contrastive


loss between this and this now the bottom part this here these are the others these


are the other images and whether the individual quantities so s is the style code of the image


you're considering right now s plus you could have already guessed it is the style code


of the augmented image right so we had our image X let's go again with X 1 X 2 X 3 are


different images so we put X 1 through the encoder that gives us s the style it also


gives us the class label but now we care about this head that gives us the style code and


we augment X 1 to be X 1 plus and we go we put that through the encoder that gives us


s plus and now we also put all of these other images remember these are the images that


we've looked at previously but the only real importance is that there are other images


we put those through here and they get the s minus I in this case three and two so now


what will require is that the s the style code of our image is closer to the style code


of its augmented version so the same principle again we want we'll say that you know these


augmentations they don't really change anything about the style now this argument is a bit


more wonky but if you think of you know random crops and random flips don't really change


anything about the fur color or so of a of a cat so we want those two to be closer together


then s is to any of these other images okay so this is a contrast of loss where you pull


together two things that you think should be close and you push apart things that you


think should be far away from each other so this style loss basically guarantees that


you have a distinct style for each image that is robust to the kind of transformations that


you do under augmentation okay specifically this style loss doesn't care about the domain


right this is for each image you don't know if these other images are from the same domain


or from different domains and that's why the style is basically individual to the image


but as we as we're going to see the style does capture something of the domain as well


but this loss right here is supposed to be each image has a style right so this is the


style code of x this n plus one way classification enables e to utilize not only the similarity


of the positive pair but also the dissimilarity of the negative pairs where the negative style


codes are stored into a queue using previously sampled images we observe that adding this


objective significantly improves unsupervised classification accuracy and animal faces from


this to that compared to the previous over clustering approach okay so we have two outputs


now and now we go to the adversarial loss so the question is how do we train the generator


and the discriminator so they have three different losses for the generator and the discriminator


and the most important one of course is this adversarial loss right here so the discriminator


simply tries to distinguish is an image real or fake conditioned on a class so in case


of a real image and that's this line right here it tries to distinguish is this real


or fake based on y and y is x fed to the encoder and the encoder gives you a label all right


that's and the label selects the head of the discriminator at the same time that the discriminator


is trying to distinguish real from fake so these two lines the generator is trying to


fool the discriminator so the upper if you've never seen a GAN loss the upper part here


that's the real data and the bottom part here is the fake data now at the same time the


discriminator is trying to distinguish real from fake and the generator is trying to make


the discriminator fool the discriminator so both are of the generator and the discriminator


are actually using that loss but the sign in front of it is different okay and since


the generator is not involved in the top line you can usually leave that away because there's


no back prop path through that and there's no back prop path here because we detach the


graph right here so there is no gradient signal going to the encoder so this bottom line what


does it mean the generator will take in an image and the style now s tilde comes from


x tilde it's x tilde going through the encoder giving you s tilde so this is the reference


image right this is you want this this style right here this is the reference image and


x is the source image so the generator is supposed to take the source image and basically


apply the style from the reference image and generate x I don't even know how to call this


x not tilde whatever x fake x f and that's supposed to fool the discriminator now the


question is which discriminator right because you need a label for the discriminator the


label is conditional with this discriminator is pretty easy because it's simply the label


of this image now however as you can see the generator learns to translate x to the target


domain while reflecting the style code s tilde so y tilde is going to be the label that comes


out of this x so this encoder right here is also going to give us y tilde and that's going


to go here alright so recap what we want to put into the discriminator is one time a real


image like we do up up here and we get its label from the encoder the encoder gets us


a label for each image very cool we'll also take the same image put it through the generator


task the generator with transferring the style of another image from here onto it we get


the style from the encoder and then the generator is supposed to make an image and we feed that


to the discriminator and the discriminator discriminates assuming it comes from class


y tilde now you see right here the generator never has access to y tilde so the generator


is kind of at a disadvantage here the discriminator gets told what kind of image it is in terms


of class while the generator because it needs to fool the discriminator it needs to come


up with an image of that class but it has no idea of the class it only has the style


code so it is forced to learn to sort of it is forced to learn to map a style to associate


a style with a particular class and that's how you get the domain into the style that's


why the style can capture something like fur color of the different cat breeds because


the generator is forced to take the style that the encoder gives and map it to an image


of the class y tilde that it also the encoder gives but doesn't tell to the generator okay


and in fact there is a more path because you now back propagate the loss to the encoder


which means that the encoder will even help the generator it will help the generator make


style codes that are very class specific now you can maybe think why why wouldn't you just


have one output why doesn't the encoder simply output the label also as the style because


that would be the easiest and the reason is because we have different losses on the style


and the label okay otherwise that would be a valid tactic so that's cool that's the adversary


loss that's the most important loss now there's also additional losses so they they do additional


losses that they add on top for the generator they say in order to prevent degenerate situation


where the generator ignores the style code and synthesizes a random image in the domain


y or in the domain y tilde we impose a style contrastive loss to the generator so now there's


still the danger that the degenerator simply produces a valid image right from the data


set or even from the domain y tilde though i don't know how it would know y tilde or


i've just not seen something in my mind it doesn't get the y tilde but it could read


it from the style but here the danger is to ignore the style i'm slightly i'm slightly


confused by this part but maybe looking at the loss will will clear it out so they say


we impose a style contrastive loss to the generator now this is almost the same as we


imposed on the encoder so the generator you can see there is a contrastive loss again


where you want to be you want these things to be close and you want these things to be


far apart so these s minuses these are going to be the ones from your the style codes of


the images from your queue so these are just going to be other images here s tilde that's


going to be the style that you get from your reference image so your reference image is


going through the encoder and that's going to give you this right here now the question


is what is s prime here because in the before we simply had s which was our source image


our source image style now what is s prime here s prime is going to be it gets more complicated


yes s prime is going to be whoops it's going to be the round trip to the encoder so it's


going to be if I generate my image from the source image x and the style s tilde of the


reference and then I ask my generate my encoder again what style does this have I get the


s prime so it's kind of a round trip right so I I take I take this I'd ask the encoder


what style is it that's s tilde right then I take s tilde go to the generator together


with a source image x and that gives me like x fake and then I ask my generator again what


style would you assign to the fake image I just produced and then the encoder will tell


you I'll give it s fake or s prime in this case and then I compare that s prime with


the one I gave before okay so it's sort of a round trip loss of my reference image right


so what does that do if I now and then I ask that s prime be close to s tilde so that means


if I generate an image with the style of my reference image the outcoming image should


better have the style of the reference image that's all it says so the style of the thing


I generate given this style they should better be close and especially closer together than


the style with any other image in my queue it makes sense but it's kind of convoluted


so you go with your out it's kind of a reconstruction loss except in style space all right and then


the last thing is an actual image reconstruction loss so what you'll do is your generator will


produce X sorry will produce an image from the source image and its own style right here


that's important before we input s tilde here so this now is we input the source image and


its own style so we go with X we go to the E and we put the style here and we tell the


generator if I input the source image and its own style then what you give me back better


be the source image itself right this is a consistency loss that tells the generator


that basically it learns now the generator learns to the generator learns to map to recognize


an image with its own style sort of because it doesn't know right it doesn't know that


what's coming in here is the style of it of the image X but now you teach it and I think


before this loss you'd have a good chance that the styles would just be all over the


place they would sort of be consistent but they will not be aligned and with this you


force that the style of an image itself if you gen if you put that into the generator


it will lead to that image itself okay that's it so this is this is extremely convoluted


right the discriminator is the easiest the discriminator is a class conditional discriminator


that gets the label from some mechanism that decides on a label right okay that's the easiest


the encoder has two parts the pseudo label which is over here which is trained completely


unsupervised detached from everything else in a self clustering approach while the style


part here is trained first of all in a contrastive way which makes sense and also in a back propagated


way from the generator so the style generation mechanism tries to help the generator okay


and that means it's going to leak some information about the label into the style because that


helps the generator the generator needs to if the generator knows what sort of class


it's going to produce it's going to be better okay so you can count on that information


being in there but also also because of all the other losses that the generator has and


the contrastive loss on the style the style code is going to sort of describe the individual


style of an image and but is also going to describe what the style of that class is because


it technically needs to contain information about the class and that's why I think this


works with the style because there is no inherent notion of like this is this is a this is the


pose of a cat or something like this yeah it still seems like a bit magic to me and


then the generator is first of all trained to fool the discriminator given an image a


source image and a style and you can fool the discriminator by producing an image that's


so good it looks real and specifically it looks real in the class that the pseudo label


has given right so in the class that the encoder has given to it so the generator must somehow


come up with an image that's of that class and so it will it will be forced to interpret


the style code in terms of that class label which makes the style code the style code


and also we have these two additional losses which is the round trip loss to the style


space so whatever the generator outputs you should be able to recover the style from it


by putting it through the encoder again and then lastly there is a consistency loss where


you say if I own put an image into a source image and I own put its own style again going


through the encoder you should give me back the source image itself very complex and all


of the generator loss is back propagated through to the encoder so this is the full loss as


I said discriminator easy adversarial loss generator adversarial loss plus this style


round trip consistency plus the own image round trip consistency encoder gets all of


the generator loss all of it so all of this goes here so the encoder fully helps the generator


and it is also trained with this mutual information and the style contrastive loss wow that's


some losses wow that that's a lot of damage so they do different investigations into their


model here and I don't even know if we've missed some of the pictures but ultimately


what you can now do is you can do image to image translation either that's the cool thing


you can have a reference image for one or what you can do is you can ask your discriminator


what kind of domains are there sorry you can ask your encoder what kind of domains are


there you've guessed the number of domains so it's maybe 10 or in this case it's 8 8


8 domains of cats and you can simply divide your data set into these 8 domains right 1


2 3 4 5 and so on now this is 10 okay I can't see anymore so 10 domains and then you can


simply calculate for each image you calculate the style vector so the style the style and


then you simply take the average one over the number in that in that domain you take


the average style vector and that's going to be your target style so you can do image


to image translation with a reference image or you can do image to image translation for


an entire group of images for example all the images in a given domain and that's how


they do these graphs right here now just quickly wait until my tablet decides to show me the


paper again thank you all right they do a bunch of investigations into their holy unholy


mixture of losses especially the first concern is couldn't we just train the guiding network


like by its own on its own and then after that train this GAN thing right that's what


we had at the very beginning we said there's this guiding network and it does the clustering


and all and couldn't we just train this GAN architecture on top of the frozen guiding


network and their conclusion is no if we train everything together it works better so on


the left you have whenever you train the guiding network by itself and what you're seeing here


is the t-SNE visualization t-SNE is a a down like a nonlinear visualization tool of style


codes extracted by our guiding network the ground truth domains of all test images is


represented in different colors so this is a data set that has labels but you don't you


don't provide the labels to this algorithm the algorithm is completely unlabeled for


but for purposes of investigating will visualize the labels with colors and what you'll see


here are the the t-SNE visualizations of the style codes so things that are close together


they have similar style codes and the ideal case would be if things that are close together


here have the same label and that means the style is sort of representative of the domain


okay that's what we want we want the style to capture the domain of an image and ideally


not the image itself too much now on the left you see that there is quite a bit of overlap


between these quite a bit of wash between the style and the group and on the right if


you jointly train the GAN together with the guiding network you see that these classes


of the style codes which have no reason to cluster are much more clustered and separated


and they are separated much more along the lines of the ground truth classes okay so


that's pretty cool now I would actually be interested in what happens if you do the separate


training with the full pipeline of this learning to classify images without labels thing and


their nearest neighbor thing because they've also shown that just purely this self clustering


doesn't work too well but if you then do the nearest neighbor thing on top then that improves


the classification significantly so this could potentially help either the separate or the


joint training right here and there might be a connection between the joint training


and whatever they're doing in any case they also show that then these FID which is a quality


metric for GANs lower is better that the joint training goes way lower in the FID than the


separate training okay that's that's the reason why they built this convoluted thing because


it works way better and here they ablate they ablate some of the losses to investigate what's


really going on and in this case t-SNE visualization of the star space of our guiding network trained


on this since this does not have ground truth domain labels each data point is colored with


the guiding networks prediction so each color is whatever the guiding network says the classes


and the dot is one style each dot is one style vector and they're projected down to two dimensions


you can see pretty clearly that the individual classes the individual clusters of style vectors


correspond to different labels of the guiding network which is to be expected but also since


they overestimate the number of classes in this case you can see that the even though


the class label is different the style network will group the very similar classes together


you can see here these are both cheetahs and here are both lions so it'll group them together


which is pretty cool and sort of verifies that it recognizes these these different things


because you force the guiding network to make 10 classes but the style network is simply


continuous so it's cool to see that the style network will make one cluster with styles


even though it's different labels and here you can see different samples from these domains


just to verify that the guiding network has actually learned to separate things I still


find this pretty pretty magical to this is completely unsupervised and it sort of finds


these clusters by itself right they have a bunch of images here as I said this is no


longer with one reference images image this is where you take the entire domain so you


self label with your guiding network and then you take the mean vector and that's going


to be your target style vector and these are the source images that you transfer and you


can see that you know works pretty well today I always have like one adult animal and one


child animal and I guess not or just two different ones here this is particularly cute though


I have to show you this Fox right here what's going on with that Fox like someone help that


Fox yeah so we're not at perfection yet as you can see but it's you know that looks like


a pretty pretty cool for maybe okay where did it go maybe it slipped maybe it's an it's


an offshoot of this one on the top left yeah who knows these data sets they have their


way and so this is sort of where you can see the limitations right here that's not how


a baby snow leopard looks you see the limitations here in that all of these animal faces they're


still pretty aligned like they're fairly frontal not exactly but they're fairly frontal pictures


they're fairly standardized and so on so we're I don't think we're yet at a level where we


can just do you know fully image to image and you see it especially with faces because


we as us humans are extremely good at you know seeing when there's something wrong with


a face but still it's still pretty impressive what's possible and I think if the past is


of any indication here is summer to winter that actually looks good if the past is of


any indication then this technology will be pushed pretty hard and soon we'll be able


to do this with a simple smartphone app or something like this so I invite you to check


out the paper right here they have lots and lots and lots of examples and t-snip plots


and whatnot in their appendix they have the code online as far as I have seen and with


Deep Differential System Stability - Learning advanced computations from examples (Paper Explained)

Hi, here's a question for the whiz kids among you. Is this system here controllable at a point xe with asymptotic control ue?


I'll give you 10 seconds. Okay, 10 seconds are over. So to solve this, it's actually pretty easy.


All you need to do is first differentiate the system with respect to its internal variables, which are the x's, to obtain the Jacobian A.


Second step, differentiate the system with respect to its control variables, which are the u variables to obtain the matrix B.


Look, this is a zero, like this is not hard. Then evaluate A and B at the point that you want and the control point that you want. Pretty easy.


Calculate the controllability matrix. Come on, that's nothing. Another zero.


And at the end, you calculate the rank of the controllability matrix. Now if the if n minus D is zero, the system is controllable.


And optionally, if you want, if you feel like it, you can output the control feedback matrix as an equation three, which gives you this here.


Now what's equation three? Equation three is super duper simple.


It's just this little sort of integral thing, inverse matrix trace transposed exponential function, outer product thing.


Come on, what's the matter with you?


Okay, so if you found you can't do this just on the spot, then you are in the same category as most people. But interestingly, apparently, according to this paper, a deep learning system can.


So today we're going to look at deep differential system stability, learning advanced computations from examples by Francois Charton, Amaury Hayat and Guillaume Lempel of Facebook AI Research and École de Pont Paris Tech and Rutgers University.


So at this, in this paper, these authors basically propose that you can learn these complex mathematics with a model that has no clue about mathematics. In fact, it is a language model.


And it can output the solutions, for example, whether or not a system is controllable, which are sort of binary solutions, but it can also output actual solutions as in numbers or as in the matrices that you would need to obtain from these problems.


So that's pretty cool. And it is built upon this other paper called, I think, some deep learning for symbolic mathematics or something, I have made a video on it, if you search for it, and I'll also link it in in the description.


And you can go check that out, because that's sort of the basis. So in this previous paper, I think it was from partially the same authors, they have investigated language models into integrating functions.


So you have some sort of function, you're trying to find the integral, and they've tried to do that. Now they go a lot further.


So they look at these differential systems, which are characterized by these differential equations. So if you've never seen differential equations, it's basically an equation where the derivation of some variable is characterized by the variable itself.


So the the, the gradient, if you will, or the coban, the derivation, according to some input variable here, it's most often it's time and physical systems is a function of that variable itself, and partially also other variables.


So you can have systems of differential equations that all depend on each other. And there are a number of questions about these systems, these are very relevant in like physics or engineering, control theory, and so on.


So they investigate different problems that you can solve with these. They investigate specifically problems where we already know the solutions, but the solutions require very complex mathematical manipulation, such as, as you've seen, calculate the integral of something, take the trace, calculate the rank, invert some matrix.


So all of these mathematical steps are required to solve these problems, if we were to teach them to math students or engineering students. And this paper basically says, if we just input the problem into a big language model, and, and ask it to output the solution, it can do it.


So basically can learn to do all of these things. So that's pretty, pretty surprising, because you don't program it to do any math. So the first problem they look at is this local stability problem.


So, in, I don't, I don't really want to go into, into much of the actual mathematical problems, but we'll look at the first one to just give you an idea of what these sort of problems are.


So, x e is an, if x is an equilibrium point, it means that all solutions, if all solutions converge to x e when their initial positions are close enough, the equilibrium point is said to be locally stable.


Okay, this problem is well known if f is differentiable in x e, and answers provided by the spectral mapping theorem.


So, in that case, you'd have a system, maybe we can draw one where you try to find local points of stability. So this point here would be maybe a local point of stability.


If you consider this as sort of an optimization landscape, because if you go from here, if you go a little bit away from it, you're always sort of pushed back. If this, if this is a, if the system is gravity, sort of, sort of.


So if these differential equations sort of describe that the height here is the force which with which you're pulled down, then this thing here would be a local point of stability.


The question is, if I give you a system that's described by these differential equations, can you tell me whether or not it is stable at some point?


Okay, and there is a spectral mapping theorem, which says, if you have the Jacobian matrix of f at this point, the matrix of its partial derivatives relative to its variable.


And if you take lambda to be the largest real part of its complex eigenvalues, if lambda is positive, then this is an unstable equilibrium.


If lambda is negative, then it's a locally stable equilibrium. So an unstable equilibrium, likewise, would be the point here on top, which means that if you're exactly at the point, then you stay there.


But as soon as you're a little bit off, you drift away from it. That would be an unstable equilibrium.


Okay, so there are complex steps involved in deriving the solution, then they list them out here, just to show you how complex this is, this is not meant to teach you.


You don't have to like understand or be able to apply this, this is simply meant to tell you how complicated it is to arrive at a solution.


So first, you need to differentiate each function with respect to each variable and obtain the formal Jacobian.


So they do this here for this example system, which is this system right here. This is a system of two equations, two differential equations in two variables.


Okay, so if you drive the Jacobian, that will give you a four entry Jacobian. So each one of these is one of the equations derived with respect to one of the variables.


You can do that, right? But it requires fairly complex mathematical knowledge, like knowing that the derivative of the sine here is the cosine and knowing that this cosine doesn't matter for this particular entry, because it's in x two, and here we drive by x one.


So that's already very challenging.


Second, you need to evaluate the Jacobian at that point. So first, you've done it symbolically. Now you actually need to put in the numbers at the point you're interested in, which will give you this thing right here, which is a numerical matrix, whereas this was a symbolical matrix.


Then you need to calculate the eigenvalues, which is mean, you have several methods of that. You have several methods of computing the largest eigenvalue, you could do power method, you could do decomposition, there, there are numerous ways, but none of these is like particularly easily, right.


And then lastly, you need to return the minus max of the real part, which is the speed of convergence of the system. So not only do you need to be able to tell whether it is stable, which is if this is negative, you also need to be able to say, or if this is negative, sorry, you need to be able to say whether it is locally stable or locally unstable.


And since this is large is larger than zero, it's locally stable. And this would be the decay rate 0.441. This is what you're asking this model to output, right? Now we'll quickly go over the other things, but not as as in depth.


But this is in control theory, where you're trying, you have almost the same thing, you have a differential equation. But now, in addition to these variables, you have these control variables, which you have power over and you trying to decide, can I control the system with the appropriate function.


And in order to do that, that's kind of the problem that we had at the beginning, I know it's not.


Oh, yeah, it is. So what you need to do is, again, differentiate the system with respect to its internal variables, differentiate the system with respect to its control variables, evaluate A and B, calculate the controllability matrix with the with one of the functions above, calculate the rank, and optionally, evaluate this equation number three that we saw before.


Now, the last task is equally complicated. It relates to the stability of partial differential equations using the Fourier transform. And again, to obtain this, it is a five step, intricate process, where that is a mix of symbolic, complex manipulation, and numerical evaluation of that symbolic things.


And here, you need to simply output two bits, one bit says whether there exists a solution, and the other bit says whether it vanishes at t to infinity.


So what are they expecting here? What they're doing is they're going to build a data set that is composed of these things. And I think they do it one by one.


So they take one of the tasks, and they're going to build a giant data set of these things, since they all have solutions, right? You can build a data set with labels, because you can actually build a you can build software that does these steps, because you program mathematical knowledge into the software, but it's custom made for that particular problem.


And they're simply trying to, they're not trying to beat that program, they're simply trying to investigate, can a language model that knows nothing of math, do this simply by learning from data.


So they're going to try to build a data set, or they are building a data set. And they do it in the same way as this previous paper, which say we generate random functions by sampling unary binary trees and randomly selecting operators, variables and integers for their internal nodes and leaves.


So they use any combination of plus minus times divide x blog, and so on. So all these functions can appear in these things. And they basically they build a tree where they say, Okay, we go from plus, and then here is five, and then here maybe is minus sin of x, and here over is x of y.


So that would be five plus sign of x minus x of y. So they build trees like this by randomly sampling. And then they simply feed this to their mathematical program to obtain a solution, y.


And then they feed all of this into that's now a training data point. This here is x, and here you have y. And they generate a giant bunch of these things. And they feed them into the into the model.


They say, here is a seek to seek models, not even sure what kind of models they use. I think they just they use transformers as well. So they use standard transformers, I believe. So yes, in all experiment, we use the transformer architecture with eight attention heads, we train our models with the atom optimizer learning rate, blah, blah, blah, we vary the dimension, and the number of layers.


So that's going to be interesting to see how the size of this language model influences how well this model can solve these things. So as you can see here, they build these data sets for local stability, they include systems with two to six equations, which is already fairly, fairly complicated, and would take a human quite a while to do this.


They say we generate a data set with over 50 million systems. So it's a pretty dense sampling of this space. And I feel this is one of the important components here.


They do make sure that none of their tests, so they do a train test split, and they do make sure that none of their test examples is in the training data set, though they claim that they never actually have to remove anything, they just check and the search space, the space of these trees here is so large, that it never happens that the that a test sample or almost never happens that a test sample is in the training data set.


Alright, so they generate these things. And here are the results. So for local stability, it is trained to predict this lambda that we saw at the beginning, the largest part of the eigenvalue of the Jacobian, corresponding to the convergence speed of equilibrium, we consider that predictions are correct when they fall within 10% of the ground truth.


And here you can see that their best model achieves 96% if the degree of if it's two equations. So if the degree of the system is two, it achieves in 96% accuracy. So in 96% of the time, the convergence speed is within 10% of the true convergence speed.


That's fairly crazy, right? That's pretty good. And here, the exact prediction of local convergence speed to a given precision. So how many digits actually match of that conversion speed, so it's not only 10% off, they also measure how many digits match.


And here, you can see that as you up the degree of equation, sorry, here, the performance drops off, as you can see, less and less and less. And also as you lower the number of layers in your model, or lower the dimensionality, the performance drops quite significantly.


So that means the language model sort of is doing real work here. And here you also see that if it's degree two, the convergence speed has pretty even goes to two, three or four digits often.


But as you now increase the degree, this accuracy drops off fairly quickly. All right, let's keep that in mind. So the surprising thing is that it actually works. And it works in surprisingly big amount of the time.


Now, I don't know, you could bicker about this 10% and how bad or how easy this is, and so on. But it is fairly, it is fairly complicated problem. And to be within 10% of the solution seems quite remarkable.


And the same things here happen with the other tasks. So here they say, they predict controllability in the autonomous case. So in the control theory, they predict these two things, whether it's controllable, and then they output this K matrix that we saw before.


Yeah. So here, you can see that if they have high enough dimensions and high enough layers with sample systems with three to six equations, they achieve again a 97% in the prediction of whether the system is controllable or not.


Now remember, this is a binary prediction, but still, it requires a good understanding of math for a human to solve this. Again, we see this drop off with dimension and layers.


But you know, the these, this, this number here is pretty good compared to the 50% you'd have for you to compare to the 50% you'd have from random guessing.


Also interesting is when they look at is this correct, this correct, sorry, is the feedback matrix correct. So this matrix that you optionally have to output, they find that if they analyze whether or not that's within 10% of the true one, they see that pretty, pretty quickly this accuracy drops when they up the degree.


Of course, the matrix, as I understand it has more entries at degree six than at degree three. So maybe that's understandable. But it drops off pretty quickly.


But what is true is whether they call this correct feedback matrix. So from the feedback matrix from the entries in that you can read out whether it's the system is controllable or not, if all of the eigenvalues, I believe, are negative or positive, or all the values are negative or positive.


So basically, by saying whether or not these things are positive or negative, you can read out the controllability. And if they check whether that property holds, then that is, is fairly well.


So they argue here that this shows that it doesn't, it doesn't predict the the matrix they want. But the matrix that it predicts has the appropriate properties to solve this other task right here.


Okay, that's experiment two. Experiment three, as you can imagine, is quite different, sorry, quite similar in that they investigate these partial differential equations.


In the Fourier transform, the model is given differential operator and an initial condition is trying to predict if a solution exists, and if so, whether it converges to zero when t goes to infinity.


The space, the dimensions between two and six. So the random guessing here would be I guess 25%. Because it's two bits, you need to output and this model performs extremely well, even up to this dimension six, there is a drop off with dimension, but it still does perform very, very well.


Now they go into the discussion a bit. And they and this, this is the part that in this paper, interests me, like how do you interpret these results, apparently, you give these mathematical things to a language model that has no clue of math.


And just by looking at examples, it learns to produce correct solutions. And if you want to teach that to a human, the human would have to go through all these steps, right? So something is happening here. And we'll want to find out what and the discussion is maybe they try to explain a bit why they think this happens.


They say, we studied five problems of advanced mathematics from widely researched about it. In three of them, we predict qualitative and theoretical features. In two, we perform numerical computations. According to mathematical theory, solving these problems requires a combination of advanced techniques, symbolic and numerical that seem unlikely to be learnable from examples.


Yet our model achieves more than 95% accuracy on all qualitative tasks, and between 65 and 85 on numerical computations, such high performances over difficult mathematical tasks may come as a surprise.


One way to generate data set of problems with their solutions consists in sampling the solution first, and deriving an associated problem. For instance, pairs of functions with their integrals can be generated by sampling and differentiating from random functions.


So here they hedge against there's this criticism. And this was mainly a criticism of their other paper, which they already addressed in their other paper was if you want to find out if you want to create a data set where you have the function, and then the label is the integral of the function, then there is no common solution to derive these integrals.


Sorry, the derive is a, there is no common solution to integrate functions. I mean, you can do it numerically, but there is no common symbolic solution to integrate any function. And that's why what you can do if you want to produce a data set is you start with the integral already.


And then you differentiate that to get to get a thing. And then you know that if you integrate this, you should get back your original function. But this biases the data set because the sampling is now not over these functions, but the sampling is over these functions.


And that might lead to this distribution here being biased. So they hedge against that, which I don't care because it clearly in this paper, and they say in this paper, data sets for all considered tasks are generated using a forward approach by directly sampling as a result, potential bias caused by backward generative model do not apply here.


And they studied problems from three to so they hedge against this argument that they could have a biased data set, which I don't think anyone reading this paper would leverage against them.


Yeah, so


in.


So here, they basically say how good they are how surprising this is all of this requires math. This part is irrelevant because it hedges against an argument that I don't think is reasonable against the paper. And then the last thing in their discussion is an objection traditionally raised is that the model might memorize a very large number of cases and interpolate between them, which I think we know in language model happens often.


Right. Oh, by the way, have I shown you how they encode this into the language model? I have not.


This is the I guess this is the craziest part. They don't even put the numbers there.


Wait, wait, they don't even put the numbers there. They actually put the as I understand it, they put the string tokens here. Right. So they put the string tokens of the math, and then even like compose.


So that number 142, they would put as now there's an integer and then the token one, the token four and the token two. Okay.


And the decimal point representation is the sequence float three dot one, four E in negative one. So this is it's really just a string, there is no, like the model would even have to learn the decimal representation of numbers to get that this four here is actually


not not just a different token than two, but it's 20 times larger because it is in the position one in front of two. So it's not two times larger, like four is the two.


But because four is, you know, one digit away from two, it's 20 times larger. And then this here is actually 50 times larger than this. So it seems like a quite inconvenient way to input data into the model. And yet the model is super accurate, right.


And we already know that these language models, what they tend to do is they tend to memorize the training data or abstracted in a way that they can sort of interpolate between fuzzy versions of the training data.


Here they say this is unlikely, sorry, this is unlikely because first because the size of our problem space is too large to be memorized.


So say for all considered problems, we did not get a single duplicate over 50 million generated examples. Second, because in some of our problems, such as non autonomous control, even a model with a one layer and 64 dimensions obtains a high accuracy and such a small model would never be able to memorize that many examples, which is true, right?


So this is, this is a fair defense against you're just interpolating training data. But I think the kind of broader, the broader scope of this criticism would be something like your model is just kind of learning the pattern regularities of the textual data that you feed in.


It's not actually learning math, it's just learning sort of, okay, there is like a cosine. And if there's a cosine here, followed by an exponential function, that often leads to like a very low number of this lambda, right.


And then if a very similar thing comes, if it comes across a very similar thing in the test sample, even though it's not exactly the same thing, it will map it to like a similar place in the label space. I mean, this is literally machine learning. This is literally regression.


But I think the more the broader scope of this criticism is that what your model might be doing might simply be sort of a very simple regression on these tokens or on the these context dependent tokens, rather than this internal mathematical reasoning.


And I don't, while it is true that it's probably not memorizing any examples, this still doesn't. And while it is also true that they did not get a single exact duplicate, what would be interesting to know is how many, like approximate duplicates.


So can you basically solve the problem with a nearest neighbor approach? That would be my question. Can you solve the problem with a nearest neighbor approach over their training data set?


Because that means you basically don't need the mathematical knowledge.


They say third, because for some of our problems, we know from mathematical theory that solutions, i.g. the real value of eigenvalues cannot be obtained by simple interpolation. And I mean, that is also a valid defense.


But I think the argument goes further than just simple interpolation. What we mean by interpolation is not we interpolate the real values of the eigenvalues. What we mean by interpolation is sort of interpolation in the regression space of these tokens.


Like we know that if we go from a sine to a cosine, maybe the sine of the output flips at the end. And that's what we mean by interpolation.


Like when we see two equations that are very similar, like x squared plus 4x minus the sine of x, and then we see x squared plus 5x minus twice the sine of x.


What we mean by interpolation is that we now get a test example that says x squared plus, let's say, 4x minus 3 times the sine of x.


Then what we would interpolate is sort of these things. Or yeah, I'm making a bad example right here.


Maybe I should go with x squared and this is x third. I know these things aren't exactly equal. But this in the middle would be sort of an interpolation in token space.


And if you train the language model, it will recognize that maybe I can interpolate whenever the coefficient here is just different or I can interpolate when there's just, you know, if there's like a log x here, that doesn't really change anything.


So I can interpolate between the two, but I might not be able to interpolate when the exponent here is different.


So if you give a training data set, you teach the model where it can interpolate and where it can't.


Now, again, it's not able to remember the training data, but it will be able to sort of abstract it and store it fuzzily and abstract the patterns from it, which is good, right?


That's machine learning. But there's no evidence here that this does any mathematical reasoning.


So up until now, all that has built up is sort of if you read the abstract, can advanced mathematical computations be learned from examples?


Neural networks can learn advanced theorems, complex computation without built in mathematical knowledge.


All of the story here, all of this, this showing of, hey, look at what all what steps is required to solve these problems.


And even this discussion here basically says, hey, you need mathematical complex reasoning to arrive at the solutions.


And then in the conclusion, in the conclusion, they say, it seems that our models have learned to solve these problems.


But that does not mean they learn these techniques we use to compute their solutions.


Problems such as non autonomous control involve long and complex chain of computations, yet even small models.


So means one layer transformers with 64 dimensions achieve high accuracy.


Most probably our models learn shortcuts that allow them to solve specific problems without having to learn or understand their theoretical background.


Such a situation is common in everyday life.


Yada, yada, yada. So here in this in this paragraph here, they sort of counter their whole narrative of the paper.


And that's I guess that's sort of to it's fair, right?


They criticize their own work, which is good for research. It's also to hedge against criticism.


And it's to be a bit real. This it's a it's a good paper, right?


Because it's a nice and interesting story. And then at the end, you also say, look, this might actually not be all that what it's made up or what it seems like to be.


And I, I agree with this statement right here.


It's that probably the model learns shortcuts, and the shortcuts might be just in a way of pattern matching the pattern matching of whatever patterns you extract from the training data, you pattern match that and you relatively simply interpolate between those matched patterns, not between the training data itself, but between the match patterns.


And therefore, you can arrive at approximately good solution.


So what I would have liked to see from such a paper, right?


They say that we leave that to future research after making really kind of big claims in the introduction and the abstract.


They have taken three different problems here, right?


There's this local, this local stability, then there is this, this control theory.


And then there is this stability, they have three different problems.


And okay, they try to show that they can apply this to a diverse range.


But what I would have expected from a paper like this is they even they even spell out, here are four things that you need to do to solve this if we were to teach this to a human, right?


Now, if you have trained a model, and you evaluated it, it is really good at this task for which you thought you need, you know, to do these four steps.


What would be really interesting is to now introspect your model and see can, can I somehow show that my model has in somewhere in the intermediate layers has this quantity right here, and is not just nearest neighboring in some learned pattern space.


That would be an actually interesting research question, right?


So rather, in my mind, rather than having three different things where they all, you know, they demonstrate the same thing over and over and over again, that this actually works.


It would be a much more interesting question to introspect the model and parse out can cannot, for example, you can see, can I reconstruct this quantity from the inside of the model, when the model isn't specifically trained to give me back this quantity,


because I know this quantity would be a step on these on the path of the solution, right?


If I want to get the solution, I almost have to calculate this quantity.