【发布时间】:2017-03-29 07:05:02
【问题描述】:
我遇到了一个以前没有发生过的问题,可能是某些规则已更改。
Traceback (most recent call last)
<ipython-input-3-f47687e192a7> in <module>()
5 n_examples = X.shape[0]
6 n_train = n_examples * 0.5
----> 7 train_idx = np.random.choice(range(0,n_examples), size=n_train, replace=False)
8 test_idx = list(set(range(0,n_examples))-set(train_idx))
9 X_train = X[train_idx]
mtrand.pyx in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:18822)()
TypeError: 'float' object cannot be interpreted as an index
【问题讨论】:
-
只是猜测,但
n_train = n_examples * 0.5可能不是整数。尝试做:n_train = int(n_examples * 0.5)?
标签: python deep-learning keras