MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / get_tensor

Method get_tensor

tensorpack/tfutils/tower.py:389–421  ·  view source on GitHub ↗

Get a tensor in this tower. The name argument can be: 1. The name of a tensor/variable without any tower prefix. 2. A name in the input signature, if it is used when building the tower. In the second case, this method will return the tensor that's used as the corr

(self, name)

Source from the content-addressed store, hash-verified

387 return self._ctx.ns_name
388
389 def get_tensor(self, name):
390 """
391 Get a tensor in this tower. The name argument can be:
392
393 1. The name of a tensor/variable without any tower prefix.
394
395 2. A name in the input signature, if it is used when building the tower.
396
397 In the second case, this method will return the tensor that's used as the corresponding
398 input to the tower. Note that this tensor may have a different name (e.g. may be an output of a queue).
399 """
400 name = get_op_tensor_name(name)[1]
401 if len(self.ns_name):
402 name_with_ns = self.ns_name + "/" + name
403 else:
404 name_with_ns = name
405
406 try:
407 ret = get_op_or_tensor_by_name(name_with_ns)
408 except KeyError:
409 if name in self._extra_tensor_names:
410 return self._extra_tensor_names[name]
411 else:
412 if name in self._extra_tensor_names:
413 mapped_tensor = self._extra_tensor_names[name]
414 logger.info(
415 "'{}' may refer to both the Tensor/Placeholder '{}' or the input to the tower '{}'.".format(
416 name, ret.name, mapped_tensor.name) +
417 " Assuming it is the input '{}'.".format(mapped_tensor.name))
418 return mapped_tensor
419 return ret
420 # should also allow variables in get_tensor
421 return self.get_variable(name)
422
423 def get_tensors(self, names):
424 """

Callers 3

get_tensorsMethod · 0.95
__getitem__Method · 0.95
load_checkpoint_varsFunction · 0.45

Calls 4

get_variableMethod · 0.95
get_op_tensor_nameFunction · 0.85
get_op_or_tensor_by_nameFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected