copyproblem.py
def generate_inputs_and_targets(delay, num_examples, num_possible_symbols=10):
  """ Generate copy-problem input, target example sequences.

  Here `delay` must be divisible by 10. This way we can specify the
  number of symbols to be copied so that a majority-vote classifier always
  results in an error rate of 1/12 (as a simple baseline that is then
  independent of `delay`).

  Example 1: `delay = 10`, `num_examples = 1`.
  Possible Inputs:  [3 B B B B B B B B B G B]
  Possible Targets: [B B B B B B B B B B B 3]

  Example 2: `delay = 20`, `num_examples = 1`.
  Possible Inputs:  [1 3 B B B B B B B B B B B B B B B B B B B G B B]
  Possible Targets: [B B B B B B B B B B B B B B B B B B B B B B 1 3]

  Args:
    delay: An integer that's divisible by 10.
    num_examples: An integer.
    num_possible_symbols: An integer.

  Returns:
    A tuple, `(inputs, targets)`. Each is a 2-D int16 array with shape
      `[num_examples, delay/10 + delay + delay/10]`.
  """

  # symbols are 0, 1, ..., num_possible_symbols - 1
  blank_symbol = num_possible_symbols
  go_symbol = num_possible_symbols + 1

  num_symbols_to_copy, remainder = divmod(delay, 10)
  if remainder != 0:
    raise ValueError('delay must be divisible by 10.')

  symbols_to_copy = np.random.randint(0, num_possible_symbols, size=[num_examples, num_symbols_to_copy], dtype=np.int16)
  blank_symbols = blank_symbol * np.ones([num_examples, 1], dtype=np.int16)
  go_symbols = go_symbol * np.ones([num_examples, 1], dtype=np.int16)

  inputs = np.concatenate([symbols_to_copy, np.tile(blank_symbols, [1, delay - 1]),
                           go_symbols, np.tile(blank_symbols, [1, num_symbols_to_copy])],
                          axis=1)

  targets = np.concatenate([np.tile(blank_symbols, [1, num_symbols_to_copy + delay]),
                            symbols_to_copy],
                           axis=1)

  return inputs, targets
 Generate copy-problem input, target example sequences.

  Here `delay` must be divisible by 10. This way we can specify the
  number of symbols to be copied so that a majority-vote classifier always
  results in an error rate of 1/12 (as a simple baseline that is then
  independent of `delay`).

  Example 1: `delay = 10`, `num_examples = 1`.
  Possible Inputs:  [3 B B B B B B B B B G B]
  Possible Targets: [B B B B B B B B B B B 3]

  Example 2: `delay = 20`, `num_examples = 1`.
  Possible Inputs:  [1 3 B B B B B B B B B B B B B B B B B B B G B B]
  Possible Targets: [B B B B B B B B B B B B B B B B B B B B B B 1 3]

  Args:
    delay: An integer that's divisible by 10.
    num_examples: An integer.
    num_possible_symbols: An integer.

  Returns:
    A tuple, `(inputs, targets)`. Each is a 2-D int16 array with shape
      `[num_examples, delay/10 + delay + delay/10]`.
  
Generate copy-problem input, target example sequences.
Here `delay` must be divisible by 10. This way we can specify the
number of symbols to be copied so that a majority-vote classifier always
results in an error rate of 1/12 (as a simple baseline that is then
independent of `delay`).




Generate copy - problem input target example sequences . Here ` delay ` must be divisible by 10 . This way we can specify the number of symbols to be copied so that a majority - vote classifier always results in an error rate of 1 / 12 ( as a simple baseline that is then independent of ` delay ` ) .
def generate_inputs_and_targets(delay, num_examples, num_possible_symbols=10):
  blank_symbol = num_possible_symbols
  go_symbol = num_possible_symbols + 1
  num_symbols_to_copy, remainder = divmod(delay, 10)
  if remainder != 0:
    raise ValueError('delay must be divisible by 10.')
  symbols_to_copy = np.random.randint(0, num_possible_symbols, size=[num_examples, num_symbols_to_copy], dtype=np.int16)
  blank_symbols = blank_symbol * np.ones([num_examples, 1], dtype=np.int16)
  go_symbols = go_symbol * np.ones([num_examples, 1], dtype=np.int16)
  inputs = np.concatenate([symbols_to_copy, np.tile(blank_symbols, [1, delay - 1]),
                           go_symbols, np.tile(blank_symbols, [1, num_symbols_to_copy])],
                          axis=1)
  targets = np.concatenate([np.tile(blank_symbols, [1, num_symbols_to_copy + delay]),
                            symbols_to_copy],
                           axis=1)
  return inputs, targets
def generate_inputs_and_targets ( delay , num_examples , num_possible_symbols = 10 ) : blank_symbol = num_possible_symbols go_symbol = num_possible_symbols + 1 num_symbols_to_copy , remainder = divmod ( delay , 10 ) if remainder != 0 : raise ValueError ( 'delay must be divisible by 10.' ) symbols_to_copy = np . random . randint ( 0 , num_possible_symbols , size = [ num_examples , num_symbols_to_copy ] , dtype = np . int16 ) blank_symbols = blank_symbol * np . ones ( [ num_examples , 1 ] , dtype = np . int16 ) go_symbols = go_symbol * np . ones ( [ num_examples , 1 ] , dtype = np . int16 ) inputs = np . concatenate ( [ symbols_to_copy , np . tile ( blank_symbols , [ 1 , delay - 1 ] ) , go_symbols , np . tile ( blank_symbols , [ 1 , num_symbols_to_copy ] ) ] , axis = 1 ) targets = np . concatenate ( [ np . tile ( blank_symbols , [ 1 , num_symbols_to_copy + delay ] ) , symbols_to_copy ] , axis = 1 ) return inputs , targets
Generate copy-problem input, target example sequences.
Generate copy - problem input target example sequences .
""" Generate copy-problem input, target example sequences.

  Here `delay` must be divisible by 10. This way we can specify the
  number of symbols to be copied so that a majority-vote classifier always
  results in an error rate of 1/12 (as a simple baseline that is then
  independent of `delay`).

  Example 1: `delay = 10`, `num_examples = 1`.
  Possible Inputs:  [3 B B B B B B B B B G B]
  Possible Targets: [B B B B B B B B B B B 3]

  Example 2: `delay = 20`, `num_examples = 1`.
  Possible Inputs:  [1 3 B B B B B B B B B B B B B B B B B B B G B B]
  Possible Targets: [B B B B B B B B B B B B B B B B B B B B B B 1 3]

  Args:
    delay: An integer that's divisible by 10.
    num_examples: An integer.
    num_possible_symbols: An integer.

  Returns:
    A tuple, `(inputs, targets)`. Each is a 2-D int16 array with shape
      `[num_examples, delay/10 + delay + delay/10]`.
  """ # symbols are 0, 1, ..., num_possible_symbols - 1
A tuple, `(inputs, targets)`. Each is a 2-D int16 array with shape
`[num_examples, delay/10 + delay + delay/10]`.
A tuple ` ( inputs targets ) ` . Each is a 2 - D int16 array with shape ` [ num_examples delay / 10 + delay + delay / 10 ] ` .
delay
An integer that's divisible by 10.
An integer that ' s divisible by 10 .
num_examples
None
num_possible_symbols
None