learning ternaries