Training code for semantics feature