用目标变量代替单一值作为阵列的多层感知器

2024-06-02 08:09:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我是新的深度学习,我一直在尝试使用theano库来训练我的数据。MLP tutorial这里有一个标量输出值,而我的用例有一个数组,其中1对应于输出中描述的值。在

例如(假设可能的标量值为0,1,2,3,4,5)

0 = [1,0,0,0,0,0]
1 = [0,1,0,0,0,0]
2 = [0,0,1,0,0,0]

我只修改了代码以读取我的输入和输出(现在的输出是一个二维数组或矩阵,用theano的说法)。代码的其他部分与上面粘贴的MLP教程一样。

我得到的错误是在以下函数中

^{pr2}$

错误堆栈:

  Traceback (most recent call last):
  File "mlp.py", line 398, in <module>
    test_mlp()
  File "mlp.py", line 286, in test_mlp
    y: test_set_y[index * batch_size:(index + 1) * batch_size]})
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/function.py", line 223, in function
    profile=profile)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 490, in pfunc
    no_default_updates=no_default_updates)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 241, in rebuild_collect_shared
    cloned_v = clone_v_get_shared_updates(outputs, copy_inputs_over)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 92, in clone_v_get_shared_updates
    clone_a(v.owner, copy_inputs_over)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 131, in clone_a
    clone_v_get_shared_updates(i, copy_inputs_over)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 92, in clone_v_get_shared_updates
    clone_a(v.owner, copy_inputs_over)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 131, in clone_a
    clone_v_get_shared_updates(i, copy_inputs_over)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 92, in clone_v_get_shared_updates
    clone_a(v.owner, copy_inputs_over)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 135, in clone_a
    strict=rebuild_strict)
  File "/usr/local/lib/python2.7/dist-packages/theano/gof/graph.py", line 213, in clone_with_new_inputs
    new_inputs[i] = curr.type.filter_variable(new)
  File "/usr/local/lib/python2.7/dist-packages/theano/tensor/type.py", line 205, in filter_variable
    self=self)<br><br>
  TypeError: Cannot convert Type TensorType(int64, matrix) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(int32, vector). You can try to manually convert Subtensor{int64:int64:}.0 into a TensorType(int32, vector).

我想知道怎么改变这个theano.功能将y值作为矩阵。在


Tags: inpyclonelibpackagesusrlocaldist