Hi:)
Is there an efficient way to create an unit vector on an n-sphere from n-1 parameters? That is I want to implement these equations (taken from wikipedia.org/wiki/N-sphere):

with r=1 s.t. I can use the result  with autograd w.r.t. phi. The fact that I want to use autograd might be a constraint since one has to pay attention if vector elements are overwritten…
Currently I am using softmax on n parameters which is not equivalent to the unit vector on n-sphere approach since there is one additional degree of freedom. The problem is that my NN occasionally generates extremely small and large values for all n parameters which is not penalize in my loss function due to the normalization of the softmax function. (The magnitude of the vector of the n parameters does not play a role in the loss function.)
Any suggestions?
Thanks for your help!