Skip to content

Commit

Permalink
update bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
qbetterk committed Jun 4, 2019
1 parent 3167359 commit 77e1a63
Show file tree
Hide file tree
Showing 13 changed files with 1,236 additions and 34 deletions.
45 changes: 14 additions & 31 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class _Config:
def __init__(self):
self._init_logging_handler()
self.cuda_device = 1
self.cuda_device = 0
self.eos_m_token = 'EOS_M'
self.beam_len_bonus = 0.5

Expand All @@ -22,9 +22,9 @@ def init_handler(self, m):
}
init_method[m]()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # this is for test different parameters # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # this is for test different parameters # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def _camrest_tsdf_init(self):
self.beam_len_bonus = 0.5
self.prev_z_method = 'separate'
Expand All @@ -35,7 +35,7 @@ def _camrest_tsdf_init(self):
self.hidden_size = 50
self.lr = 0.003
self.dropout_rate = 0.3
self.maml_step=2
self.maml_step=7

self.split = (9, 1, 5)
self.lr_decay = 0.5
Expand Down Expand Up @@ -424,9 +424,9 @@ def _camrest_tsdf_init(self):
# # self.db = '../SimDial/1500_data_fixed/restaurant_style-MixSpec-150-DB.json'
# # self.entity = '../SimDial/1500_data_fixed/restaurant_style-MixSpec-150-OTGY.json'

# # self.model_path = './models/fixed_r_w_b3.pkl'
# # self.result_path = './results/fixed_r_w_b3.csv'
# # self.result_path = './results/fixed_r_w_b3-r.csv'
# self.model_path = './models/fixed0_r_w_b3.pkl'
# self.result_path = './results/fixed0_r_w_b3.csv'
# # # self.result_path = './results/fixed_r_w_b3-r.csv'
# # self.result_path = './results/fixed_r_w_b3-m.csv'
# # self.result_path = './results/fixed_r_w_b3-r_slot.csv'
# # self.result_path = './results/fixed_r_w_b3-r_style.csv'
Expand Down Expand Up @@ -779,21 +779,10 @@ def _camrest_tsdf_init(self):

# self.enlarge_vocab = False

# # self.vocab_path = './vocab/vocab-camrest.pkl'
# # self.data = './data/CamRest676/CamRest676.json'
# # self.entity = './data/CamRest676/CamRestOTGY.json'
# # self.db = './data/CamRest676/CamRestDB.json'

# self.vocab_path = '../sequicity_orig/vocab/vocab-rest_weat_bus.pkl'
# # # restaurant
# # self.data = '../SimDial/1500_data/restaurant-MixSpec-1500.json'
# # self.db = '../SimDial/1500_data/restaurant-MixSpec-1500-DB.json'
# # self.entity = '../SimDial/1500_data/restaurant-MixSpec-1500-OTGY.json'

# # restaurant Pitt
# self.data = '../SimDial/1500_data/rest_pitt-MixSpec-1500.json'
# self.db = '../SimDial/1500_data/rest_pitt-MixSpec-1500-DB.json'
# self.entity = '../SimDial/1500_data/rest_pitt-MixSpec-1500-OTGY.json'
# self.vocab_path = './vocab/vocab-camrest.pkl'
# self.data = './data/CamRest676/CamRest676.json'
# self.entity = './data/CamRest676/CamRestOTGY.json'
# self.db = './data/CamRest676/CamRestDB.json'

# self.glove_path = './data/glove/glove.6B.50d.txt'
# self.batch_size = 32
Expand All @@ -808,14 +797,8 @@ def _camrest_tsdf_init(self):
# self.max_ts = 40
# self.early_stop_count = 3
# self.new_vocab = True
# # self.model_path = './models/camrest.pkl'
# # self.result_path = './results/camrest-rl.csv'

# self.model_path = './models/rest_weat_bus.pkl'
# # self.result_path = './results/rest_weat_bus.csv'
# # self.result_path = './results/rest_weat_bus-movie.csv'
# # self.result_path = './results/rest_weat_bus-rest_nomaml.csv'
# self.result_path = './results/rest_weat_bus-rest_slot_nomaml.csv'
# self.model_path = './models/camrest.pkl'
# self.result_path = './results/camrest-rl.csv'

# self.teacher_force = 100
# self.beam_search = False
Expand Down
4 changes: 2 additions & 2 deletions metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ def match_metric(self, data, sub='match',raw_data=None):
# pdb.set_trace()
#############################
match += 1
else:
print(gen_cons, truth_cons)
# else:
# print(gen_cons, truth_cons)

# #############################
# pdb.set_trace()
Expand Down
3 changes: 3 additions & 0 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ def eval(self, data='test'):
u_input, u_input_np, z_input, m_input, m_input_np, u_len, \
m_len, degree_input, kw_ret \
= self._convert_batch(turn_batch, prev_z)
################################
pdb.set_trace()
##################################
m_idx, z_idx, turn_states = self.m(mode=mode, u_input=u_input, u_len=u_len, z_input=z_input,
m_input=m_input,
degree_input=degree_input, u_input_np=u_input_np,
Expand Down
6 changes: 5 additions & 1 deletion reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ def wrap_result(self, turn_batch, gen_m, gen_z, eos_syntax=None, prev_z=None):
if write_header:
self.result_file.write('START_CSV_SECTION\n')
writer.writeheader()

################################
pdb.set_trace()
##################################
writer.writerows(results)
return results

Expand Down Expand Up @@ -619,7 +623,7 @@ def _construct(self, data_json_path, db_json_path):
else:
self.vocab.load_vocab(cfg.vocab_path)
encoded_data = self._get_encoded_data(tokenized_data)
random.shuffle(encoded_data)
# random.shuffle(encoded_data)
self.train, self.dev, self.test = self._split_data(encoded_data, cfg.split)
random.shuffle(self.train)
random.shuffle(self.dev)
Expand Down
95 changes: 95 additions & 0 deletions run_bus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash

set -xeu


# s=15
# ss=$s
# cuda=5
# for idx in 1 2 3 4 5 6 7 8 9
# do
# # barely test

# python model.py -mode test \
# -model tsdf-camrest \
# -cfg data="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500.json" \
# db="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-DB.json" \
# entity="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-OTGY.json" \
# vocab_path="./vocab/vocab-fixed${idx}_r_w_m_${s}b.pkl" \
# model_path="./models/fixed${idx}_r_w_m${ss}.pkl" \
# result_path="./results/fixed${idx}_r_w_m${ss}-r.csv" \
# cuda_device=${cuda}

# # # adaptation

# cp ./models/fixed${idx}_r_w_m${ss}.pkl ./models/fixed${idx}_r_w_m${ss}_adpb.pkl

# python model.py -mode adjust \
# -model tsdf-camrest \
# -cfg data="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-${s}.json" \
# db="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-${s}-DB.json" \
# entity="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-${s}-OTGY.json" \
# vocab_path="./vocab/vocab-fixed${idx}_r_w_m_${s}b.pkl" \
# model_path="./models/fixed${idx}_r_w_m${ss}_adpb.pkl" \
# result_path="./results/fixed${idx}_r_w_m${ss}_adpb-b.csv" \
# cuda_device=${cuda}

# # test again
# python model.py -mode test \
# -model tsdf-camrest \
# -cfg data="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500.json" \
# db="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-DB.json" \
# entity="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-OTGY.json" \
# vocab_path="./vocab/vocab-fixed${idx}_r_w_m_${s}b.pkl" \
# model_path="./models/fixed${idx}_r_w_m${ss}_adpb.pkl" \
# result_path="./results/fixed${idx}_r_w_m${ss}_adpb-b.csv" \
# cuda_device=${cuda}

# done


# # # #transfer learning
s=15
ss=$s
cuda=5
for idx in 1 2 3 4 5 6 7 8 9
do
# # barely test

# python model.py -mode test \
# -model tsdf-camrest \
# -cfg data="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500.json" \
# db="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-DB.json" \
# entity="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-OTGY.json" \
# vocab_path="./vocab/vocab-fixed${idx}_r_w_m_${s}b.pkl" \
# model_path="./models/orig_fixed${idx}_r_w_m${ss}.pkl" \
# result_path="./results/orig_fixed${idx}_r_w_m${ss}-r.csv" \
# cuda_device=${cuda}

# # adaptation

cp ../sequicity_orig/models/fixed${idx}_r_w_m${ss}.pkl ./models/orig_fixed${idx}_r_w_m${ss}_adpb.pkl

python model.py -mode adjust \
-model tsdf-camrest \
-cfg data="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-${s}.json" \
db="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-${s}-DB.json" \
entity="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-${s}-OTGY.json" \
vocab_path="./vocab/vocab-fixed${idx}_r_w_m_${s}b.pkl" \
model_path="./models/orig_fixed${idx}_r_w_m${ss}_adpb.pkl" \
result_path="./results/orig_fixed${idx}_r_w_m${ss}_adpb-b.csv" \
cuda_device=${cuda}

# test again
python model.py -mode test \
-model tsdf-camrest \
-cfg data="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500.json" \
db="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-DB.json" \
entity="../SimDial/1500_data_fixed_${idx}/bus-MixSpec-1500-OTGY.json" \
vocab_path="./vocab/vocab-fixed${idx}_r_w_m_${s}b.pkl" \
model_path="./models/orig_fixed${idx}_r_w_m${ss}_adpb.pkl" \
result_path="./results/orig_fixed${idx}_r_w_m${ss}_adpb-b.csv" \
cuda_device=${cuda}

done

Loading

0 comments on commit 77e1a63

Please sign in to comment.