title: Google Colab Notebook Error - File not found
body: <p>I am running the code below in the Google Colab notebook. I am facing very odd problem related to File not Found error. Both 'atis.test.pkl' and 'atis.train.pkl' are in the same folder (c:\users\downloads). The code is not throwing error for 'atis.train.pkl', but for 'atis.test.pkl', it is giving error 'File not Found'.</p>
  
  <p>The traceback is as follows:</p>
  
  <pre><code>Done  loading:  ./atis.train.pkl
        samples: 4978    vocab_size:  943
  
  
  slot count:  129  intent count:   26 Query text: BOS what are the seating capacities of planes between pittsburgh and baltimore EOS Query vector:  [178 916 228 827 750 285 646 686 259 682 215 247 179] Intent label:  capacity Slot text:  O O O O O O O O O B-fromloc.city_name O B-toloc.city_name O Slot vector:  [128, 128, 128, 128, 128, 128, 128, 128, 128, 48, 128, 78, 128]
  ************************************************************************** Query text: BOS okay i would like to know the type of aircraft used on a flight from cleveland to dallas please EOS Query vector:  [178 653 479 932 545 851 516 827 883 646 196 892 654 180 428 444 304 851  339 688 179] Intent label:  aircraft Slot text:  O O O O O O O O O O O O O O O O B-fromloc.city_name O B-toloc.city_name O O Slot vector:  [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 48, 128, 78, 128, 128]
  ************************************************************************** Query text: BOS i 'm planning a trip to pittsburgh and i live in denver can you help me EOS Query vector:  [178 479   3 687 180 870 851 682 215 479 553 482 351 282 938 467 581 179] Intent label:  flight Slot text:  O O O O O O O B-toloc.city_name O O O O B-fromloc.city_name O O O O O Slot vector:  [128, 128, 128, 128, 128, 128, 128, 78, 128, 128, 128, 128, 48, 128, 128, 128, 128, 128]
  ************************************************************************** Query text: BOS i would like an early morning flight from chicago into seattle on continental airlines EOS Query vector:  [178 479 932 545 214 388 606 428 444 297 497 752 654 325 200 179] Intent label:  flight Slot text:  O O O O O B-depart_time.period_of_day B-depart_time.period_of_day O O B-fromloc.city_name O B-toloc.city_name O B-airline_name I-airline_name O Slot vector:  [128, 128, 128, 128, 128, 33, 33, 128, 128, 48, 128, 78, 128, 2, 83, 128]
  ************************************************************************** Query text: BOS show me the flights from boston to philadelphia EOS Query vector:  [178 770 581 827 429 444 266 851 678 179] Intent label: flight Slot text:  O O O O O O B-fromloc.city_name O B-toloc.city_name O Slot vector:  [128, 128, 128, 128, 128, 128, 48, 128, 78, 128]
  **************************************************************************
  --------------------------------------------------------------------------- FileNotFoundError                         Traceback (most recent call last) &lt;ipython-input-24-861a72e5a86c&gt; in &lt;module&gt;()
       70 
       71 # load ATIS testing dataset
  ---&gt; 72 t2i_test, s2i_test, in2i_test, i2t_test, i2s_test, i2in_test, input_tensor_test, target_tensor_test, query_data_test, intent_data_test, intent_data_label_test, slot_data_test = load_atis('atis.test.pkl')
  
  1 frames &lt;ipython-input-24-861a72e5a86c&gt; in load_ds(fname, verbose)
        6 # load Pickle file
        7 def load_ds(fname, verbose=True):
  ----&gt; 8     with open(fname, 'rb') as stream:
        9         ds,dicts = pickle.load(stream)
       10     if verbose:
  
  FileNotFoundError: [Errno 2] No such file or directory: './atis.test.pkl'
  </code></pre>
  
  <p>The code is as follows:</p>
  
  <pre><code>import pickle
  import numpy as np
  DATA_DIR="."
  
  # load Pickle file 
  def load_ds(fname, verbose=True):
      with open(fname, 'rb') as stream:
          ds,dicts = pickle.load(stream)
      if verbose:
        print('Done  loading: ', fname)
        print('      samples: {:4d}'.format(len(ds['query'])))
        print('   vocab_size: {:4d}'.format(len(dicts['token_ids'])))
        print('   slot count: {:4d}'.format(len(dicts['slot_ids'])))
        print(' intent count: {:4d}'.format(len(dicts['intent_ids'])))
      return ds,dicts
  
  # convert Pickle file to arrays
  def load_atis(filename, add_start_end_token=False, verbose=True):
      train_ds, dicts = load_ds(os.path.join(DATA_DIR,filename), verbose)
      t2i, s2i, in2i = map(dicts.get, ['token_ids', 'slot_ids','intent_ids'])
      i2t, i2s, i2in = map(lambda d: {d[k]:k for k in d.keys()}, [t2i,s2i,in2i])
      query, slots, intent =  map(train_ds.get, ['query', 'slot_labels', 'intent_labels'])
  
      if add_start_end_token:
          i2s[178] = 'BOS'
          i2s[179] = 'EOS'
          s2i['BOS'] = 178
          s2i['EOS'] = 179
  
      input_tensor = []
      target_tensor = []
      query_data = []
      intent_data = []
      slot_data = []
      to_show = np.random.randint(0, len(query)-1, 5)
      for i in range(len(query)):
          input_tensor.append(query[i])
          slot_text = []
          slot_vector = []
          for j in range(len(query[i])):
              slot_text.append(i2s[slots[i][j]])
              slot_vector.append(slots[i][j])
          if add_start_end_token:
              slot_text[0] = 'BOS'
              slot_vector[0] = 178
              slot_text[-1] = 'EOS'
              slot_vector[-1]= 179
          target_tensor.append(slot_vector)
          q = ' '.join(map(i2t.get, query[i]))
          query_data.append(q.replace('BOS', '').replace('EOS',''))
          intent_data.append(i2in[intent[i][0]])
          slot = ' '.join(slot_text)
          slot_data.append(slot[1:-1])
          if i in to_show and verbose:
            print('Query text:', q)
            print('Query vector: ', query[i])
            print('Intent label: ', i2in[intent[i][0]])
            print('Slot text: ', slot)
            print('Slot vector: ', slot_vector)
            print('*'*74)
      query_data = np.array(query_data)
      intent_data = np.array(intent_data)
      slot_data = np.array(slot_data)
      intent_data_label = np.array(intent).flatten()
      return t2i, s2i, in2i, i2t, i2s, i2in, input_tensor, target_tensor, query_data, intent_data, intent_data_label, slot_data
  
  # load ATIS training dataset
  t2i_train, s2i_train, in2i_train, i2t_train, i2s_train, i2in_train, input_tensor_train, target_tensor_train, query_data_train, intent_data_train, intent_data_label_train, slot_data_train = load_atis('atis.train.pkl')
  
  # load ATIS testing dataset
  t2i_test, s2i_test, in2i_test, i2t_test, i2s_test, i2in_test, input_tensor_test, target_tensor_test, query_data_test, intent_data_test, intent_data_label_test, slot_data_test = load_atis('atis.test.pkl')
  
  
  
  </code></pre>