  Although artificial neural networks have recently been proven to provide a
promising new framework for constructing quantum many-body wave functions, the
parameterization of a quantum wavefunction with nonabelian symmetries in terms
of a Boltzmann machine inherently leads to biased results due to the basis
dependence. We demonstrate that this problem can be overcome by sampling in the
basis of irreducible representations instead of spins, for which the
corresponding ansatz respects the nonabelian symmetries of the system. We apply
our methodology to find the ground states of the one-dimensional
antiferromagnetic Heisenberg (AFH) model with spin-half and spin-1 degrees of
freedom, and obtain a substantially higher accuracy than when using the
$s_z$-basis as input to the neural network. The proposed ansatz can target
excited states, which is illustrated by calculating the energy gap of the AFH
model. We also generalize the framework to the case of anyonic spin chains.
