在 DL 教程中,我试图根据 将“输入”传递给 Theano 中的函数的目的/意义是什么来打印测试样本的概率? 但我收到以下错误。我需要添加一些 theano_flags 吗?
如何解决问题?
TypeError: 无法将 Type Generic (of Variable ) 转换为 Type TensorType(float64, matrix)。您可以尝试手动转换为 TensorType(float64, matrix)。
(我的数据的特征数=120,classes=2,test_set batch size=1)
部分代码是:
从theano导入pp
classifier = LogisticRegression(input=x, n_in=120, n_out=2)
print " Theano builds graphs for the expressions it computes before evaluating them:that is..."
print pp(classifier.p_y_given_x)
.........................
# test it on the test set
test_losses = [test_model(i)
for i in xrange(n_test_batches)]
test_score = numpy.mean(test_losses)
values=theano.shared(value=test_set_x.get_value)
f=theano.function([],classifier.p_y_given_x,
givens={x:values},on_unused_input='ignore')
print f()