MCPcopy Create free account
hub / github.com/HazyResearch/spacetime / forward

Method forward

model/network.py:91–112  ·  view source on GitHub ↗
(self, u)

Source from the content-addressed store, hash-verified

89 # Forward pass
90 # ------------
91 def forward(self, u):
92 self.set_closed_loop(True)
93 # Assume u.shape is (batch x len x dim),
94 # where len = lag + horizon
95 z = self.embedding(u)
96 z = self.encoder(z)
97 y_c, _ = self.decoder(z)
98 y_c = self.output(y_c) # y_c is closed-loop output
99
100 if not self.inference_only:
101 # Also compute outputs via open-loop
102 self.set_closed_loop(False)
103 y_o, z_u = self.decoder(z)
104 y_o = self.output(y_o) # y_o is "open-loop" output
105 # Prediction and "ground-truth" for next-time-step
106 # layer input (i.e., last-layer output)
107 z_u_pred, z_u_true = z_u
108 else:
109 y_o = None
110 z_u_pred, z_u_true = None, None
111 # Return (model outputs), (model last-layer next-step inputs)
112 return (y_c, y_o), (z_u_pred, z_u_true)

Callers

nothing calls this directly

Calls 1

set_closed_loopMethod · 0.95

Tested by

no test coverage detected