You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining a custom network, the Network class attempts to build by calling tensor_spec.sample_spec_nest to sample an input.
Line 134 in tf_agents/network/network.py:
def _build(self):
if not self.built and self.input_tensor_spec is not None:
random_input = tensor_spec.sample_spec_nest(
self.input_tensor_spec, outer_dims=(1,))
step_type = tf.expand_dims(time_step.StepType.FIRST, 0)
self.__call__(random_input, step_type, None)
However, sample_spec_nest attempts to convert each part of the input tensor spec to a BoundedTensorSpec.
Line 331 in tf_agents/specs/tensor_spec.py:
This results in a TypeError when a custom network consumes a (for example) Boolean array as part of its input.
For instance:
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tf_agents/networks/network.py", line 179, in trainable_variables
self._build()
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tf_agents/networks/network.py", line 135, in _build
self.input_tensor_spec, outer_dims=(1,))
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tf_agents/specs/tensor_spec.py", line 338, in sample_spec_nest
return tf.nest.map_structure(sample_fn, structure)
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tensorflow_core/python/util/nest.py", line 536, in map_structure
structure[0], [func(*x) for x in entries],
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tensorflow_core/python/util/nest.py", line 536, in <listcomp>
structure[0], [func(*x) for x in entries],
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tf_agents/specs/tensor_spec.py", line 332, in sample_fn
spec = BoundedTensorSpec.from_spec(spec)
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/tensor_spec.py", line 258, in from_spec
minimum = getattr(spec, "minimum", dtype.min)
File "/home/em/projects/ActiveDialogue/venv/lib/python3.6/site-packages/tensorflow_core/python/framework/dtypes.py", line 186, in min
raise TypeError("Cannot find minimum value of %s." % self)
TypeError: Cannot find minimum value of <dtype: 'bool'>
Is there a recommended workaround for this issue?
The text was updated successfully, but these errors were encountered:
ericzhao28
changed the title
Network._build assumption of BoundedArraySpec
Network._build assumes input array spec is bounded
Aug 23, 2019
When defining a custom network, the
Network
class attempts to build by callingtensor_spec.sample_spec_nest
to sample an input.Line 134 in
tf_agents/network/network.py
:However,
sample_spec_nest
attempts to convert each part of the input tensor spec to a BoundedTensorSpec.Line 331 in
tf_agents/specs/tensor_spec.py
:This results in a TypeError when a custom network consumes a (for example) Boolean array as part of its input.
For instance:
Is there a recommended workaround for this issue?
The text was updated successfully, but these errors were encountered: