OneHot.ftl 527 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=${size})
        <#include "OutputShape.ftl">
6
<#elseif mode == "FORWARD_FUNCTION">
Christian Fuß's avatar
Christian Fuß committed
7
        ${element.name} = self.${element.name}(${input})
8
9
10
11
12
13
<#elseif mode == "PYTHON_INLINE">
                    ${element.name} = nd.one_hot(indices=${input}, depth=${size})
<#elseif mode == "CPP_INLINE">
    vector<float> ${element.name}(${size}, 0);
    ${element.name}[${input}[0]] = 1;
</#if>