(self, x1, x2, x3)
| 66 | self.linear_h3, self.linear_o3 = nn.Identity(), nn.Identity() |
| 67 | |
| 68 | def forward(self, x1, x2, x3): |
| 69 | |
| 70 | if self.gate_h1: |
| 71 | h1 = self.linear_h1(x1) #breaks colli of h1 |
| 72 | z1 = self.linear_z1(x1, torch.cat([x2,x3], dim=-1)) if self.use_bilinear[0] else self.linear_z1(torch.cat((x1, x2, x3), dim=-1)) #creates a vector combining both modalities |
| 73 | o1 = self.linear_o1(nn.Sigmoid()(z1)*h1) #update modality input |
| 74 | else: |
| 75 | h1 = self.linear_h1(x1) |
| 76 | o1 = self.linear_o1(h1) |
| 77 | |
| 78 | if self.gate_h2: |
| 79 | h2 = self.linear_h2(x2) |
| 80 | z2 = self.linear_z2(x2, torch.cat([x1,x3], dim=-1)) if self.use_bilinear[1] else self.linear_z2(torch.cat((x1, x2, x3), dim=-1)) |
| 81 | o2 = self.linear_o2(nn.Sigmoid()(z2)*h2) |
| 82 | else: |
| 83 | h2 = self.linear_h2(x2) |
| 84 | o2 = self.linear_o2(h2) |
| 85 | |
| 86 | if self.gate_h3: |
| 87 | h3 = self.linear_h3(x3) |
| 88 | z3 = self.linear_z3(x3, torch.cat([x1,x2], dim=-1)) if self.use_bilinear[2] else self.linear_z3(torch.cat((x1, x2, x3), dim=-1)) |
| 89 | o3 = self.linear_o3(nn.Sigmoid()(z3)*h3) |
| 90 | else: |
| 91 | h3 = self.linear_h3(x3) |
| 92 | o3 = self.linear_o3(h3) |
| 93 | |
| 94 | return o1, o2, o3 |
| 95 | |
| 96 | class FC_block(nn.Module): |
| 97 | def __init__(self, dim_in, dim_out, act_layer=nn.ReLU, dropout=True, p_dropout_fc=0.25): |
nothing calls this directly
no outgoing calls
no test coverage detected