有各类型之间的差异<type 'numpy.string_'>和<type 'str'>?
我正在使用"multiclass.OneVsRestClassifier"和"cross_validation.StratifiedKFold".当我对多标签问题进行交叉验证时,它会失败.是否可以对多标签问题进行交叉验证scikit-learn?
我认为问题出在类标签列表的元组Eg([1],[2],[2],[1],[1,2],[3],[1,2,3] ...... )
我相信这个错误的代码如下:
n_samples = X.shape[0]
Y_list = [value for value in Y.T]
print 'Y_list[0].shape:', Y_list[0].shape, 'len(Y_list):', len(Y_list)
cv = cross_validation.StratifiedKFold(Y_list, 3)
Run Code Online (Sandbox Code Playgroud) python svm scikit-learn cross-validation multilabel-classification
我试图对简单的代码执行急切的执行。
我在Jupyter Notebook和Spyder IDE上都尝试过。使用Jupyter,我没有问题,但是当我在Spyder中执行代码时,它将返回错误:
File "C:\...\lib\site-packages\tensorflow\python\framework\ops.py", line 5496, in enable_eager_execution "tf.enable_eager_execution must be called at program startup.")
ValueError: tf.enable_eager_execution must be called at program startup.
Run Code Online (Sandbox Code Playgroud)
代码如下:
import tensorflow as tf
tf.enable_eager_execution ()
import tensorflow.contrib.eager as tfe
def square (x):
return tf.multiply (x, x)
grad = tfe.gradients_function (square)
print (grad (3.))
Run Code Online (Sandbox Code Playgroud)