【问题标题】:CNTK sends an error regarding 'sequence.gather' operatorCNTK 发送有关“sequence.gather”运算符的错误
【发布时间】:2019-04-26 19:46:22
【问题描述】:

我正在尝试使用“sequence.gather”运算符创建模型,但在调用“train_minibatch”时出现错误“Where operation can only operation on scalar input”。

input_seq_axis = Axis('inputAxis')
input_sequence = sequence.input_variable(shape=vocab_dim, sequence_axis=input_seq_axis)
vowel_mask_sequence = sequence.input_variable(shape=2, sequence_axis=input_seq_axis)
a = Sequential([
    C.layers.Recurrence(C.layers.LSTM(hidden_dim)),
    ])
b=C.sequence.gather(a(input_sequence),vowel_mask_sequence)
z=Dense(3)(b)
label_sequence = sequence.input_variable(3, sequence_axis=z.dynamic_axes[1])

我该如何解决这个错误?我什至不使用 'where' 运算符。

【问题讨论】:

    标签: neural-network cntk


    【解决方案1】:

    对于sequence.gather(x, y),y必须是标量,也就是说:

    assert y.shape == (1,)
    

    y 的值必须为 0 或 1,并且与 x 具有完全相同的动态轴。

    关于如何使用我维护的库中的sequence.gatherexample

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      • 2012-07-19
      • 1970-01-01
      相关资源
      最近更新 更多