(tensor_dict, batch_size)
return tiled_dict
Tile scalar tensors in the dictionary to have batch dimension.
Tile scalar tensors in the dictionary to have batch dimension.
Tile scalar tensors in the dictionary to have batch dimension .
def _tile_scalar_to_batch_size(tensor_dict, batch_size):
  """Tile scalar tensors in the dictionary to have batch dimension."""
  # bool(tf.constant(1).shape) = True.
  # this is inconsistent with python default length test. Disable pylint.
  scalar_keys = [k for k, v in tensor_dict.items() if len(v.shape) == 0]  # pylint: disable=g-explicit-length-test
  tiled_dict = {}
  for k, v in tensor_dict.items():
    if k in scalar_keys:
      logging.info("Expand scalar to vector: %s", k)
      v = tf.tile(tf.reshape(v, [1]), [batch_size])
    tiled_dict[k] = v
  return tiled_dict
def _tile_scalar_to_batch_size ( tensor_dict , batch_size ) : # bool(tf.constant(1).shape) = True. # this is inconsistent with python default length test. Disable pylint. scalar_keys = [ k for k , v in tensor_dict . items ( ) if len ( v . shape ) == 0 ] # pylint: disable=g-explicit-length-test tiled_dict = { } for k , v in tensor_dict . items ( ) : if k in scalar_keys : logging . info ( "Expand scalar to vector: %s" , k ) v = tf . tile ( tf . reshape ( v , [ 1 ] ) , [ batch_size ] ) tiled_dict [ k ] = v return tiled_dict