OneHot.ftl 655 Bytes
Newer Older
Christian Fuß's avatar
Christian Fuß committed
1
2
3
<#assign input = element.inputs[0]>
<#assign size = element.size>
<#if mode == "ARCHITECTURE_DEFINITION">
4
5
            self.${element.name} = OneHot(size=${element.element.outputTypes[0].dimensions[0]})
            <#include "OutputShape.ftl">
6
<#elseif mode == "FORWARD_FUNCTION">
Christian Fuß's avatar
Christian Fuß committed
7
        ${element.name} = self.${element.name}(${input})
8
<#elseif mode == "PYTHON_INLINE">
9
                    ${element.name} = nd.one_hot(indices=${input}, depth=${element.element.outputTypes[0].dimensions[0]})
10
<#elseif mode == "CPP_INLINE">
11
    vector<float> ${element.name}(${element.element.outputTypes[0].dimensions[0]}, 0);
12
13
    ${element.name}[${input}[0]] = 1;
</#if>