You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While executing Random sampling code I am getting error in
def get_random_samples(matrix, n_samples, crop_width):
"""
Get N random samples with width of crop_width from the numpy matrix
representing the participant's audio spectrogram.
"""
# crop full spectrogram into segments of width = crop_width
clipped_mat = matrix[:, (matrix.shape[1] % crop_width):]
n_splits = clipped_mat.shape[1] / crop_width
cropped_sample_ls = np.split(clipped_mat, n_splits, axis=1)
# get random samples
samples = random.sample(cropped_sample_ls, n_samples)
return samples
usr/lib/python3.7/random.py in sample(self, population, k)
320 if not 0 <= k <= n:
321 raise ValueError("Sample larger than population or is negative")
--> 322 result = [None] * k
323 setsize = 21 # size of a small set minus size of an empty list
324 if k > 5:
TypeError: can't multiply sequence by non-int of type 'float'
The text was updated successfully, but these errors were encountered:
While executing Random sampling code I am getting error in
def get_random_samples(matrix, n_samples, crop_width):
"""
Get N random samples with width of crop_width from the numpy matrix
representing the participant's audio spectrogram.
"""
# crop full spectrogram into segments of width = crop_width
clipped_mat = matrix[:, (matrix.shape[1] % crop_width):]
n_splits = clipped_mat.shape[1] / crop_width
cropped_sample_ls = np.split(clipped_mat, n_splits, axis=1)
# get random samples
samples = random.sample(cropped_sample_ls, n_samples)
return samples
usr/lib/python3.7/random.py in sample(self, population, k)
320 if not 0 <= k <= n:
321 raise ValueError("Sample larger than population or is negative")
--> 322 result = [None] * k
323 setsize = 21 # size of a small set minus size of an empty list
324 if k > 5:
TypeError: can't multiply sequence by non-int of type 'float'
The text was updated successfully, but these errors were encountered: