Yoda is not mourning the death of the Jedi after order 66.
He is physically responding to the disturbance in the force caused by the death of so many powerful Jedi.
The same way Obi Wan reacted in Episode 4 when Alderaan was destroyed.
Edited to add:
The part where Yoda is actually attacked was left out of the novelization but later, when Obi Wan freaks out about the children, this dialog occurs:
"We took them from their homes.
"
Obi-Wan fought to stay in his chair; the pain inside him demanded motion.
It became wave after wave of tremors.
"We promised their families—" "Control yourself, you must; still Jedi, you are!"
"
Yes, Master Yoda.
" That scab on his knuckle—focused on that, he could suppress the shaking.
"Yes, we are Jedi.
But what if we're the last?"
"If the last we are, unchanged our duty is.
" Yoda settled his chin onto hands folded over the head of his gimer stick.
He looked every day of his nearly nine hundred years. "
While one Jedi lives, survive the Order does.
Resist the darkness with every breath, we must.
"
He lifted his head and the stick angled to poke Obi-Wan in the shin. "
Especially the darkness in ourselves, young one.
Of the dark side, despair is."
The simple truth of this called to him.
Even despair is attachment: it is a grip clenched upon pain.
Slowly, very slowly, Obi-Wan Kenobi remembered what it was to be a Jedi.
So in this scene from the novelization
Yoda is clearly saying not to grieve for the dead Jedi.
It is not in the movie
and I am not clear if novelization is considered canon or not, but
well... it's here.
scifi.stackexchange.com/users/32606/MikeV
The difference is that a single Jedi dying is part of the cycle of Life.
That Jedi unites with the Force, and that is not something to mourn.
But the killing of all Jedi is not part of the cycle, and causes disequilibrium in the Force (and the galaxy).
Not any single one of the killed Jedi is to be mourned: they are all reuniting with the Force, but the fact that they all are being killed is to be mourned.
scifi.stackexchange.com/users/21161/Envite
A different take on Envite's answer (+1, by the way), is that Yoda isn't mourning for the ones that are dying, but rather, for the ones that are doing the killing.
scifi.stackexchange.com/users/21287/João Mendes
Yoda also trains Luke even after insisting that he's too old to begin Jedi training.
And advises him that he should never use the force as a weapon for attack, despite the Jedi having been a major combatative force in the Clone Wars.
Yoda in the prequels is learning that his own advice, that the advice of the Jedi council, does not always work .
This is a repeated theme in the original trilogy - that the Jedi's own pride and refusal to change is what led to their downfall.
scifi.stackexchange.com/users/20533/Zibbobz
Contrary to popular desire, Yoda is not necessarily the most perfect being in the universe.
If he was, perhaps he could instantaneously bring balance back to the force at the snap of his fingers.
So then, if all these other great answers are somehow incorrect, another possibility is that he is in fact mourning the death of so many Jedi.
In other words, while he has intellectual assent to his own principle of not mourning Jedi when they die, and when only a few of them dies at a time he is able to emotionally handle it, he is not able to do so when nearly ALL of them die.
It's analogous to when you see him easily lift small objects with the force, but is then visibly straining when you see him lift extremely massive objects.
I don't think canon intends to make him out to be perfect.
Just saying. :)
scifi.stackexchange.com/users/35536/OCDev
Perhaps it is the difference between someone dying a natural death, and someone being killed.
One is the conclusion of a life, while the other is a life being cut short.
He is mourning the tragedy of the Empire's genocide and the loss of all of the potential good contained within the Jedi Order, rather than just the loss of a friend.
scifi.stackexchange.com/users/35570/user35570
In Episode 3, Yoda tells Anakin,    Rejoice for those around us who transform into the Force. Mourn them, do not. Miss them, do not. Attachment leads to jealousy, the shadow of greed, that is.   However, as Order 66 is executed, it shows Yoda most definitely mourning for the Jedi who are currently being slaughtered.  Why doesn't Yoda hold true to his own advice and rejoice those who have transformed into the Force?
Why does Yoda mourn the Jedi after Order 66 is executed?
scifi.stackexchange.com
<star-wars><yoda><order-66>
scifi.stackexchange.com/questions/71610
scifi.stackexchange.com/users/35448/Scottie
Yoda is clearly saying not to grieve for the dead Jedi.  Yoda is not mourning the death of the Jedi after order 66, he is mourning the tragedy of the Empire's genocide. Although Yoda is not mourning the loss of the Jedi per se, it is possible he is mourning their death since they are dying unnaturally and as a result of genocide. 
Yoda is not mourning the loss of the Jedi being killed. He learns that his own advice is not always practical. It is possible Yoda is mourning the death of the Jedi since they are dying unnaturally and as a result of genocide. 