v5 refactor works but crossentropy error returns nan sometimes