def compress_weights(W, l):
 (U, s, V) = np.linalg.svd(W, full_matrices=False)
 Ul = U[:, :l]
 sl = s[:l]
 Vl = V[:l, :]
 L = np.dot(np.diag(sl), Vl)
 return (Ul, L)

def compress_weights ( W , l ) : ( U , s , V ) = np . linalg . svd ( W , full_matrices = False ) Ul = U [ : , : l ] sl = s [ : l ] Vl = V [ : l , : ] L = np . dot ( np . diag ( sl ) , Vl ) return ( Ul , L )
compress the weight matrix w of an inner product layer using truncated svd .