MCPcopy Create free account
hub / github.com/coperception/star / encode

Method encode

star/models/CNNNet.py:102–156  ·  view source on GitHub ↗

Encode the input BEV features. Args: x (tensor): the input BEV features. Returns: A list that contains all the encoded layers.

(self, x)

Source from the content-addressed store, hash-verified

100 self.bn_decompress = nn.BatchNorm2d(256)
101
102 def encode(self, x):
103 """Encode the input BEV features.
104
105 Args:
106 x (tensor): the input BEV features.
107
108 Returns:
109 A list that contains all the encoded layers.
110 """
111 batch, seq, z, h, w = x.size()
112
113 x = x.view(-1, x.size(-3), x.size(-2), x.size(-1))
114 x = x.to(torch.float)
115 x = F.relu(self.bn_pre_1(self.conv_pre_1(x)))
116 x = F.relu(self.bn_pre_2(self.conv_pre_2(x)))
117
118 # -------------------------------- Encoder Path --------------------------------
119 # -- STC block 1
120 x_1 = F.relu(self.bn1_1(self.conv1_1(x)))
121 x_1 = F.relu(self.bn1_2(self.conv1_2(x_1)))
122
123 x_1 = x_1.view(
124 batch, -1, x_1.size(1), x_1.size(2), x_1.size(3)
125 ).contiguous() # (batch, seq, c, h, w)
126 x_1 = self.conv3d_1(x_1)
127 x_1 = x_1.view(
128 -1, x_1.size(2), x_1.size(3), x_1.size(4)
129 ).contiguous() # (batch * seq, c, h, w)
130
131 # -- STC block 2
132 x_2 = F.relu(self.bn2_1(self.conv2_1(x_1)))
133 x_2 = F.relu(self.bn2_2(self.conv2_2(x_2)))
134
135 x_2 = x_2.view(
136 batch, -1, x_2.size(1), x_2.size(2), x_2.size(3)
137 ).contiguous() # (batch, seq, c, h, w)
138 x_2 = self.conv3d_2(x_2)
139 x_2 = x_2.view(
140 -1, x_2.size(2), x_2.size(3), x_2.size(4)
141 ).contiguous() # (batch * seq, c, h, w), seq = 1
142
143 # -- STC block 3
144 x_3 = F.relu(self.bn3_1(self.conv3_1(x_2)))
145 x_3 = F.relu(self.bn3_2(self.conv3_2(x_3)))
146
147 # -- STC block 4
148 x_4 = F.relu(self.bn4_1(self.conv4_1(x_3)))
149 x_4 = F.relu(self.bn4_2(self.conv4_2(x_4)))
150
151 # compress x_3 (the layer that agents communicates on)
152 if self.compress_level > 0:
153 x_3 = F.relu(self.bn_compress(self.com_compresser(x_3)))
154 x_3 = F.relu(self.bn_decompress(self.com_decompresser(x_3)))
155
156 return [x, x_1, x_2, x_3, x_4]
157
158 def decode(
159 self,

Callers 1

forwardMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected