Transform a matrix to have determinant 1

Is there a smooth function $f$ that I can apply to a matrix $\mathbf{A}$ such that $\det(f(\mathbf{A}))=1$? The transformation should have the property such that $\forall \mathbf{B} \in SO(n), \exists \mathbf{A} : f(\mathbf{A})=\mathbf{B}$, ie. there exists some input to this function such that every rotation matrix can be realized for a given dimension $n$.

Motivation:

I've been playing around with using matrices instead of vectors in a deep learning model for natural language processing. When using "word vectors", it's useful to normalize them onto a unit sphere. This gives the vectors nice properties and is easy to do. I'd like to replace these vectors with matrices, specifically rotation matrices. However, a deep learning model will attempt any arbitrary values as input and I'd like to somehow "normalize" them into a proper rotation.


Solution 1:

How about $$f(A)=\exp(A-A^t)?$$ Here $A^t$ is the transpose of $A$. The image of this is $\text{SO}(n)$.