【问题标题】:CNTK LSTM How to define data of sequence to sequenceCNTK LSTM 如何定义序列到序列的数据
【发布时间】:2018-01-22 01:55:54
【问题描述】:

当我的数据看起来像这样时:

1      |x 3:1 |y 8:1
1      |x 4:1 |y 
1      |x 5:1 |y 
1      |x 6:1 |y 
1      |x 7:1 |y 

我的变量是这样声明的:

var features = Variable.InputVariable(new int[] { inputDim }, DataType.Float, featuresName, null, true);
var labels = Variable.InputVariable(new int[] { numOutputClasses }, DataType.Float, labelsName, new List<Axis>() { Axis.DefaultBatchAxis() }, true);

然后代码可以工作,但是当我希望我的网络产生序列时 --> 序列,所以我的数据看起来像这样:

1      |x 3:1 |y 4:1
1      |x 4:1 |y 5:1
1      |x 5:1 |y 6:1
1      |x 6:1 |y 7:1
1      |x 7:1 |y 8:1

我得到这个错误:

Unhandled Exception: System.ArgumentOutOfRangeException: 
The dimension size (5) of the axis (1) of the Value ('[10 x 5 x 20]') 
must be 1, because this axis is not specified as a dynamic axis of 
the Variable ('Input('labels', [10], [#])').

我如何告诉 CNTK 这没关系,我想在序列的每一步输出,所以我认为它应该有这些数据,这是一个经典的多对多 LSTM。但要么 CNTK c# api 坏了,要么我只是不知道如何告诉它我想要做什么(很可能)。

10 个输入,10 个输出,第一个序列中有 5 个元素,我的批次中有 20 个序列。

【问题讨论】:

    标签: c# lstm cntk rnn


    【解决方案1】:

    诀窍是删除:new List&lt;Axis&gt;() { Axis.DefaultBatchAxis() } 从标签来看,默认是允许一个序列,这意味着“这不是一个序列”,doh!

    例如

    var labels = Variable.InputVariable(
                     new int[] { numOutputClasses },
                     DataType.Float,
                     labelsName,
                     null,
                     true
                 );
    

    顺便说一句,您必须确保您的网络模型也不会破坏序列,所以不要使用CNTKLib.SequenceLast(LSTMFunction) :-)

    感谢 KeDengMS 向我解释这个问题 :-)

    【讨论】:

      猜你喜欢
      • 2017-05-24
      • 1970-01-01
      • 2016-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多