Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error in Random Sampling Code #16

Open
UmaYadav opened this issue Aug 19, 2021 · 2 comments
Open

Getting error in Random Sampling Code #16

UmaYadav opened this issue Aug 19, 2021 · 2 comments

Comments

@UmaYadav
Copy link

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'

@arrnavvv
Copy link

Were you able to solve it?

@UmaYadav
Copy link
Author

Were you able to solve it?

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants