MCPcopy Create free account
hub / github.com/apache/singa / compile

Method compile

examples/cnn_ms/pkg_model_code/model.py:159–187  ·  view source on GitHub ↗

Compile and initialize the model This function will automatically derive the shape of parameters in each sublayer based on the shape of input placeholders. It will also do some settings. Args: inputs(list): the list of input tensors(placeholders)

(self, inputs, is_train=True, use_graph=False, sequential=False)

Source from the content-addressed store, hash-verified

157 self._results = None
158
159 def compile(self, inputs, is_train=True, use_graph=False, sequential=False):
160 """ Compile and initialize the model
161
162 This function will automatically derive the shape of parameters
163 in each sublayer based on the shape of input placeholders. It will
164 also do some settings.
165
166 Args:
167 inputs(list): the list of input tensors(placeholders)
168 is_train(bool): when is_trainis True, this model will enter
169 training mode, otherwise it will enter the evaluation mode
170 use_graph(bool): when use_graph is True, computational graph
171 will be used to train this model
172 sequential(bool): when sequential is True, model will execute ops
173 in the graph follow the order of joining the graph
174 """
175 assert len(inputs) > 0 and isinstance(inputs[0], Tensor), (
176 'compile function expects PlaceHolders or Tensors')
177
178 dev = inputs[0].device
179 dev.EnableGraph(True)
180 self.forward(*inputs)
181 dev.EnableGraph(False)
182 dev.ResetGraph()
183
184 autograd.training = is_train
185 self.training = is_train
186 self.graph_mode = use_graph
187 self.sequential = sequential
188
189 def forward(self, *input):
190 """Defines the computation performed in every forward propagation.

Callers 15

runFunction · 0.45
mlp.pyFile · 0.45
qabot_train.pyFile · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45

Calls 3

forwardMethod · 0.95
EnableGraphMethod · 0.80
ResetGraphMethod · 0.80

Tested by

no test coverage detected