MCPcopy Create free account
hub / github.com/AIRMEC/HECTOR / Categorical_encoding

Class Categorical_encoding

model.py:110–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 return x
109
110class Categorical_encoding(nn.Module):
111 def __init__(self, taxonomy_in=3, embedding_dim=128, depth=1, act_fct='relu', dropout=True, p_dropout=0.25):
112 super(Categorical_encoding, self).__init__()
113
114 act_fcts = {'relu': nn.ReLU(),
115 'elu' : nn.ELU(),
116 'tanh': nn.Tanh(),
117 'selu': nn.SELU(),
118 }
119 dropout_module = nn.AlphaDropout(p_dropout) if act_fct=='selu' else nn.Dropout(p_dropout)
120
121 self.embedding = nn.Embedding(taxonomy_in, embedding_dim)
122
123 fc_layers = []
124 for d in range(depth):
125 fc_layers.append(nn.Linear(embedding_dim//(2**d), embedding_dim//(2**(d+1))))
126 fc_layers.append(dropout_module if dropout else nn.Identity())
127 fc_layers.append(act_fcts[act_fct])
128
129 self.fc_layers = nn.Sequential(*fc_layers)
130
131 def forward(self, x):
132 x = self.embedding(x)
133 x = self.fc_layers(x)
134 return x
135
136class HECTOR(nn.Module):
137 def __init__(

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected