Reputation: 31
Is it possible to take the norm of different instances without looping in a for loop? ex.
Given a numpy array of shape (10,2048) -> 10 instances of 2048 features, I want to take the norm of each instance minus the average of the instances, then take the norm of each instance, and sum them up. Here is the for loop equivalent, with x being data instead of 0's
x = np.zeros((10,2048))
sum = 0
for i in range(10):
sum += np.norm(x[i] - np.mean(x))
Upvotes: 0
Views: 117