CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

BrainScript macros do not properly interpret tag

Open wdarling opened this issue 10 years ago • 4 comments

Hi, the ElementDivide operator is implemented as a BS macro as follows: ElementDivide(aMatrix, anotherMatrix, tag='') = ElementTimes(aMatrix, Reciprocal(anotherMatrix), tag). When I try to write out the network that includes the line v2 = ElementDivide(v0, v1, tag='output'), I get the following exception:

Validating --> v0 = InputValue() :  -> [1 x *]
Validating --> v1 = LearnableParameter() :  -> [1]
Validating --> v2.anotherMatrix = Reciprocal (v1) : [1] -> [1]
Validating --> v2 = ElementTimes (v0, v2.anotherMatrix) : [1 x *], [1] -> [1 x *]
...
EXCEPTION occurred: There is no default output node specified in the network.

If I switch my use of ElementDivide to ElementTimes as v2 = ElementTimes(v0, v1, tag='output') then things work fine:

Validating --> v0 = InputValue() :  -> [1 x *]
Validating --> v1 = LearnableParameter() :  -> [1]
Validating --> v2 = ElementTimes (v0, v1) : [1 x *], [1] -> [1 x *]

So despite passing the tag to ElementTimes in the definition of ElementDivide, it doesn't seem to pick it up...

wdarling avatar Apr 08 '16 14:04 wdarling

Note: the current implementation of ElementDivide in CNTK.core.bs does not have the tag included in the parameters to ElementTimes(aMatrix, Reciprocal(anotherMatrix)) but even in my branch with it included I still have the problem..

wdarling avatar Apr 08 '16 14:04 wdarling

Ok, I sorted it out :smiley: ElementDivide has to be implemented as ElementTimes(aMatrix, Reciprocal(anotherMatrix), tag=tag).

Does this seem like the right approach or should tags automatically be forwarded?

wdarling avatar Apr 08 '16 15:04 wdarling

I've checked in a fix for ElementDivide. It is now as noted in the above comment.

wdarling avatar Apr 08 '16 15:04 wdarling

Hi William, BrainScript is not officially supported yet. This incorrect forwarding is on my list. Saying tag=tag might work in NDL, but I think it should give you a cyclic dependence error. Instead, in the future you will be able to say tag=^.tag to refer to an element in an outer context.

frankseide avatar Apr 11 '16 19:04 frankseide