parameters: (args)
return_statement: return init_states
docstring: set atual shape of data
docstring_summary: set atual shape of data
docstring_tokens: set atual shape of data
function: def prepare_data(args):
      """
      set atual shape of data
      """
      rnn_type = args.config.get("arch", "rnn_type")
      num_rnn_layer = args.config.getint("arch", "num_rnn_layer")
      num_hidden_rnn_list = json.loads(args.config.get("arch", "num_hidden_rnn_list"))
  
      batch_size = args.config.getint("common", "batch_size")
  
      if rnn_type == 'lstm':
          init_c = [('l%d_init_c' % l, (batch_size, num_hidden_rnn_list[l]))
                    for l in range(num_rnn_layer)]
          init_h = [('l%d_init_h' % l, (batch_size, num_hidden_rnn_list[l]))
                    for l in range(num_rnn_layer)]
      elif rnn_type == 'bilstm':
          forward_init_c = [('forward_l%d_init_c' % l, (batch_size, num_hidden_rnn_list[l]))
                            for l in range(num_rnn_layer)]
          backward_init_c = [('backward_l%d_init_c' % l, (batch_size, num_hidden_rnn_list[l]))
                             for l in range(num_rnn_layer)]
          init_c = forward_init_c + backward_init_c
          forward_init_h = [('forward_l%d_init_h' % l, (batch_size, num_hidden_rnn_list[l]))
                            for l in range(num_rnn_layer)]
          backward_init_h = [('backward_l%d_init_h' % l, (batch_size, num_hidden_rnn_list[l]))
                             for l in range(num_rnn_layer)]
          init_h = forward_init_h + backward_init_h
      elif rnn_type == 'gru':
          init_h = [('l%d_init_h' % l, (batch_size, num_hidden_rnn_list[l]))
                    for l in range(num_rnn_layer)]
      elif rnn_type == 'bigru':
          forward_init_h = [('forward_l%d_init_h' % l, (batch_size, num_hidden_rnn_list[l]))
                            for l in range(num_rnn_layer)]
          backward_init_h = [('backward_l%d_init_h' % l, (batch_size, num_hidden_rnn_list[l]))
                             for l in range(num_rnn_layer)]
          init_h = forward_init_h + backward_init_h
      else:
          raise Exception('network type should be one of the lstm,bilstm,gru,bigru')
  
      if rnn_type == 'lstm' or rnn_type == 'bilstm':
          init_states = init_c + init_h
      elif rnn_type == 'gru' or rnn_type == 'bigru':
          init_states = init_h
      return init_states
function_tokens: def prepare_data ( args ) : rnn_type = args . config . get ( "arch" , "rnn_type" ) num_rnn_layer = args . config . getint ( "arch" , "num_rnn_layer" ) num_hidden_rnn_list = json . loads ( args . config . get ( "arch" , "num_hidden_rnn_list" ) ) batch_size = args . config . getint ( "common" , "batch_size" ) if rnn_type == 'lstm' : init_c = [ ( 'l%d_init_c' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] init_h = [ ( 'l%d_init_h' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] elif rnn_type == 'bilstm' : forward_init_c = [ ( 'forward_l%d_init_c' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] backward_init_c = [ ( 'backward_l%d_init_c' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] init_c = forward_init_c + backward_init_c forward_init_h = [ ( 'forward_l%d_init_h' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] backward_init_h = [ ( 'backward_l%d_init_h' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] init_h = forward_init_h + backward_init_h elif rnn_type == 'gru' : init_h = [ ( 'l%d_init_h' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] elif rnn_type == 'bigru' : forward_init_h = [ ( 'forward_l%d_init_h' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] backward_init_h = [ ( 'backward_l%d_init_h' % l , ( batch_size , num_hidden_rnn_list [ l ] ) ) for l in range ( num_rnn_layer ) ] init_h = forward_init_h + backward_init_h else : raise Exception ( 'network type should be one of the lstm,bilstm,gru,bigru' ) if rnn_type == 'lstm' or rnn_type == 'bilstm' : init_states = init_c + init_h elif rnn_type == 'gru' or rnn_type == 'bigru' : init_states = init_h return init_states