ubuntu训练习惯记录(abspath,os.getcwd(),nohup等)

常规设置 

#!/usr/bin/env bash

dataset="$1"
GPUNAME="$2"

PYTHON=~/anaconda3_py3.7/bin/python
nohup $PYTHON teacher_training.py $dataset $GPUNAME  result_001.log 21 

设置显卡和当前路径获取----上一路径获取

import os
import sys
DATASET = sys.argv[1]
os.environ['CUDA_VISIBLE_DEVICES'] = sys.argv[2]



cur_dir = os.path.abspath(os.path.dirname(__file__))
before_dir = os.path.abspath(os.path.join(os.getcwd(),".."))

顺序训练:

import subprocess


python_path = "/root/train/results/new/anaconda3_py3.7/bin/python"

A = subprocess.run(python_path + " resnet18_training.py mydata 1", shell=True, check=True)
B = subprocess.run(python_path + " teacher_training.py mydata 1", shell=True, check=True)
C = subprocess.run(python_path + " students_training.py mydata 1", shell=True, check=True)
#!/usr/bin/env bash

PYTHON=/root/train/results/new/anaconda3_py3.7/bin/python
nohup $PYTHON test_process.py  test_result.log 21 

其他:

    #测试集 L-id R-id 每个id两个数据
    test_key = [str(m_key)+"-"+str(n_key) for m_key in range(0, 100) for n_key in range(0, 1000)]
    test_dict = {}.fromkeys(test_key, 0)
coupling_dict = {
    'R1-P007-C005-I005': 100,
    'R2-P004-C005-I005': 200,
}
lines = list(coupling_dict.keys())

 

最新回复(0)
/jishuOK_2F_2Fe4pjORPQKDeaVJ7JdRJvVXROd82m14cShg_3D_3D4795333
8 简首页