我第一次使用theano。我正在使用这个tutorial代码,我用这种方式定义了一些共享变量:
train_set_x_sh = theano.shared(np.asarray(train_set_x))
train_set_y_sh = theano.shared(np.asarray(train_set_y))
train_model = theano.function(
inputs=[index],
outputs=cost,
updates=updates,
givens={
x: train_set_x_sh[index * batch_size: (index + 1) * batch_size],
y: train_set_y_sh[index * batch_size: (index + 1) * batch_size]
}
)
但是,当我想使用这些共享变量时,我遇到了这个错误:
ValueError: dimension mismatch in args to gemm (20,52)x(784,500)->(20,500)
Apply node that caused the error: GpuDot22(GpuSubtensor{int32:int32:}.0, W)
Toposort index: 14
Inputs types: [CudaNdarrayType(float32, matrix),CudaNdarrayType(float32, matrix)]
Inputs shapes: [(20, 52), (784, 500)]
Inputs strides: [(52, 1), (500, 1)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[GpuElemwise{Composite{tanh((i0 + i1))}}[(0, 0)](GpuDot22.0, GpuDimShuffle{x,0}.0)]]