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

ValueError: Sample larger than population or is negative while testing #70

Open
nidhikamath91 opened this issue Oct 6, 2018 · 0 comments

Comments

@nidhikamath91
Copy link

nidhikamath91 commented Oct 6, 2018

Below is my code for testing and I am getting this error

import data
import data_utils
import seq2seq

import importlib

load data from pickle and npy files

metadata, idx_q, idx_a = data.load_data(PATH='./')
(trainX, trainY), (testX, testY), (validX, validY) = data_utils.split_dataset(idx_q, idx_a)

parameters

xseq_len = trainX.shape[-1]
yseq_len = trainY.shape[-1]
batch_size = 16
xvocab_size = len(metadata['idx2w'])
yvocab_size = xvocab_size
emb_dim = 1024

importlib.reload(seq2seq)

model = seq2seq.Seq2Seq(xseq_len=xseq_len,
yseq_len=yseq_len,
xvocab_size=xvocab_size,
yvocab_size=yvocab_size,
ckpt_path='./ckpt',
emb_dim=emb_dim,
num_layers=3
)
val_batch_gen = data_utils.rand_batch_gen(validX, validY, 256)
test_batch_gen = data_utils.rand_batch_gen(testX, testY, 256)
train_batch_gen = data_utils.rand_batch_gen(trainX, trainY, batch_size)

sess = model.restore_last_session()

input_ = test_batch_gen.next()[0]
output = model.predict(sess, input_)
print(output.shape)

replies = []
for ii, oi in zip(input_.T, output):
q = data_utils.decode(sequence=ii, lookup=metadata['idx2w'], separator=' ')
decoded = data_utils.decode(sequence=oi, lookup=metadata['idx2w'], separator=' ').split(' ')
if decoded.count('unk') == 0:
if decoded not in replies:
print('q : [{0}]; a : [{1}]'.format(q, ' '.join(decoded)))
replies.append(decoded)

the error is as below

C:\Users\d074437\PycharmProjects\seq2seq>python test.py
2018-10-06 11:22:00.982163: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Building Graph Traceback (most recent call last):
File "test.py", line 39, in
input_ = test_batch_gen.next()[0]
File "C:\Users\d074437\PycharmProjects\seq2seq\data_utils.py", line 38, in rand_batch_gen
sample_idx = sample(list(np.arange(len(x))), batch_size)
File "C:\Users\d074437\AppData\Local\Programs\Python\Python36\lib\random.py", line 320, in sample
raise ValueError("Sample larger than population or is negative")
ValueError: Sample larger than population or is negative

Please let me know how to proceed

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

1 participant