OneHot.ftl 537 Bytes
Newer Older
Christian Fuß's avatar
Christian Fuß committed
1
<#assign input = element.inputs[0]>
2
<#assign size = element.size?c>
Christian Fuß's avatar
Christian Fuß committed
3
<#if mode == "ARCHITECTURE_DEFINITION">
Sebastian Nickels's avatar
Sebastian Nickels committed
4
            self.${element.name} = OneHot(size=${size})
5
            <#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">
Sebastian Nickels's avatar
Sebastian Nickels committed
9
                    ${element.name} = nd.one_hot(indices=${input}, depth=${size})
10
<#elseif mode == "CPP_INLINE">
Sebastian Nickels's avatar
Sebastian Nickels committed
11
    vector<float> ${element.name}(${size}, 0);
12
13
    ${element.name}[${input}[0]] = 1;
</#if>