fix: adversarial instruction summmary with REVERIE format
This commit is contained in:
parent
ce1ac697cd
commit
d02bb2332c
45
adversarial_summary.py
Normal file
45
adversarial_summary.py
Normal file
@ -0,0 +1,45 @@
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
def remove_non_ascii(text):
|
||||
return re.sub(r'[^\x00-\x7F]', ' ', text)
|
||||
|
||||
|
||||
|
||||
for file in ['train', 'val_unseen', 'val_seen', 'test']:
|
||||
print(file)
|
||||
if os.path.isfile('data/adversarial/reverie_{}_fnf.json'.format(file)):
|
||||
with open('data/adversarial/reverie_{}_fnf.json'.format(file)) as fp:
|
||||
data = json.load(fp)
|
||||
|
||||
|
||||
result = {}
|
||||
for i in data:
|
||||
instruction_id = i['id']
|
||||
if instruction_id not in result:
|
||||
result[instruction_id] = {
|
||||
'distance': float(i['distance']),
|
||||
'ix': int(i['ix']),
|
||||
'scan': i['scan'],
|
||||
'id': i['id'],
|
||||
'instructions_l': i['instructions_l'],
|
||||
'path_id': int(i['path_id']),
|
||||
'objId': i['objId'],
|
||||
'path': i['path'],
|
||||
'heading': float(i['heading']),
|
||||
'instructions': [ remove_non_ascii(i['instruction'])],
|
||||
'found': [ i['found'] ],
|
||||
}
|
||||
else:
|
||||
result[instruction_id]['instructions'].append(remove_non_ascii(i['instruction']))
|
||||
result[instruction_id]['found'].append( i['found'] )
|
||||
|
||||
output = []
|
||||
for k, item in result.items():
|
||||
output.append(item)
|
||||
else:
|
||||
output = []
|
||||
|
||||
with open('data/adversarial/REVERIE_{}.json'.format(file), 'w') as fp:
|
||||
json.dump(output, fp)
|
||||
24
run/agent.bash
Normal file
24
run/agent.bash
Normal file
@ -0,0 +1,24 @@
|
||||
name=reverie-v4.2.1
|
||||
flag="--description reverie-v4.2.1
|
||||
|
||||
--train listener
|
||||
--features places365
|
||||
|
||||
--test_only 0
|
||||
--maxAction 15
|
||||
--maxInput 50
|
||||
--batchSize 4
|
||||
--feedback sample
|
||||
--lr 1e-5
|
||||
--iters 200000
|
||||
--optim adamW
|
||||
|
||||
--attn soft
|
||||
--mlWeight 0.20
|
||||
--featdropout 0.4
|
||||
--angleFeatSize 128
|
||||
--subout max
|
||||
--dropout 0.5"
|
||||
|
||||
mkdir -p snap/$name
|
||||
CUDA_VISIBLE_DEVICES=0 python3 r2r_src/train.py $flag --name $name
|
||||
Loading…
Reference in New Issue
Block a user