private static SDVariable nonZeroCount ( SDVariable weights , SDVariable labels ) { SameDiff sd = weights . getSameDiff ( ) ; SDVariable present = sd . neq ( weights , 0.0 ) ; SDVariable presentBroadcast = sd . zerosLike ( labels ) . add ( present ) ; return sd . sum ( presentBroadcast ) ; }
Determine the number of weight entries that are non - zero after broadcasting