vmtmxmf5 / Pytorch-

pytorch로 머신러닝~딥러닝 구현
3 stars 0 forks source link

많은 변수를 관리해야 한다면? #8

Open vmtmxmf5 opened 3 years ago

vmtmxmf5 commented 3 years ago
def add_1(x):
    return (x + 2, 1, 1, 1, 1, 1)

def mul_2(x):
    return x * 2

v_lst = [v for v in range(5)]
variables = [add_1(v) for v in v_lst]
lng_names = ['en', 'ja', 'zh']

for lng, v in zip(lng_names, v_lst):
    globals()['tmp_src_{}'.format(lng)] = add_1(v)
    globals()['tmp_tgt_{}'.format(lng)] = add_1(v*2)

    a = globals()['tmp_src_{}'.format(lng)]
    b = globals()['tmp_tgt_{}'.format(lng)]

    globals()['tmp2_src_{}'.format(lng)] = mul_2(a)
    globals()['tmp2_tgt_{}'.format(lng)] = mul_2(b)