Loading TOC...

cntk:rnn-step-layer

cntk:rnn-step-layer(
   $x as cntk:variable,
   $additional-parameters as map:map,
   [$go-backwards as xs:boolean],
   [$initial-states as cntk:constant*],
   [$return-full-state as xs:boolean],
   [$name as xs:string]
) as cntk:function

Summary

Layer factory function to create a RNN Step layer.

Parameters
$x
$additional-parameters

"shape": xs:unsignedLong*.

"cell-shape": xs:unsignedLong*.

"activation": xs:string. Default: "tanh"

"use-peepholes": xs:boolean. Default: false.

"init": xs:double, or cntk:value, or cntk:initializer. Default: cntk:glorot-uniform-initializer().

"bias-init": xs:double, or cntk:value, or cntk:initializer. Default: 0.

"enable-self-stablization": xs:boolean. Default: false.

"name": xs:string. Default: ""

$go-backwards
$initial-states
$return-full-state
$name

Example

xquery version "1.0-ml";

let $num-classes := 2
let $num-samples := 5
let $num-sequences := 8
let $input-shape := cntk:shape((64))
let $input-variable := cntk:input-variable($input-shape, "float", fn:false(), fn:false(), "input")
let $rnn-step-block-option := map:map()=>
                          map:with("shape", (100))
let $rnn-step-output := cntk:function-outputs(cntk:rnn-step-layer($input-variable, $rnn-step-block-option))[1]
let $last-rnn-step-output := cntk:sequence-last($rnn-step-output)
let $dense-option := map:map()=>
                     map:with("output-shape", cntk:shape(($num-classes)))
let $dense-output := cntk:dense-layer($last-rnn-step-output, $dense-option)
let $input-value-array := json:to-array(for $i in (1 to $num-sequences) return json:to-array((1 to cntk:shape-total-size($input-shape)*$num-samples)))
let $input-value := cntk:batch-of-sequences($input-shape, $input-value-array, for $i in (1 to $num-sequences) return fn:true())
let $label-shape := cntk:shape(($num-classes))
let $label-variable := cntk:input-variable($label-shape, "float",fn:false(), fn:false(), "label",(cntk:default-batch-axis()))
let $label-array := json:to-array(for $i in (1 to $num-sequences) return (0,1))
let $label-value := cntk:batch($label-shape, $label-array)
let $learner := cntk:sgd-learner((cntk:function-parameters($dense-output)), cntk:learning-rate-schedule-from-constant(0.1))
let $loss := cntk:cross-entropy-with-softmax($dense-output, $label-variable,cntk:axis(0))
let $trainer := cntk:trainer($dense-output, ($learner), $loss)
let $input-pair := json:to-array(($input-variable, $input-value))
let $label-pair := json:to-array(($label-variable, $label-value))
let $minibatch := json:to-array(($input-pair, $label-pair))
return cntk:train-minibatch($trainer, $minibatch, fn:true())

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.