作者:deavilacampuzano | 来源:互联网 | 2023-09-23 13:59
我是深度学习和使用Amazon Web服务的新手,我有一个(非常)基本的问题要问。
我似乎已经想出了如何通过AWS Batch在Amazon EC2服务器上运行我的Python代码,但是我感到困惑,因为一旦服务器完成运行我的代码,我不知道如何从我的实例中检索代码结果
例如,假设我有一个python文件/Users/dev/Code_154.py
,
,然后在我的Amazon EC2实例上运行Code_154
。代码Code_154.py
的内容为:
# define attain_weight_loop function
def attn_weight_loop(test_i,nlayer,best_model):
attn_tensor = torch.zeros(test_i.size()[1],test_i.size()[0]).float()
# replace every 0's in attn_tensor to -1
torch.where(attn_tensor == 0.0,torch.tensor(-2.0),attn_tensor)
for m in range(test_i.size()[1]):
input_ids = test_i[:,m]
input_ids = torch.tensor(input_ids.tolist()).unsqueeze(0)
outputs = best_model(input_ids)
for k in range(test_i.size()[0]):
for j in range(nlayer):
# extract mean attention weights of batch m,token k,at layer j
# (i.e. across all heads and the sequence)
#
attn_mean_list_k = []
attn_mean = torch.mean(outputs[4][j][0,:,k])
attn_mean = [attn_mean]
attn_mean_list_k = attn_mean_list_k + attn_mean
for z in range(len(attn_mean_list_k)):
attn_mean_list_chunk_k = attn_mean_list_k[:z+1]
attn_tensor[m,z,k] = multiply_list(attn_mean_list_chunk_k)
return attn_tensor
# execute attain_weight_loop
attn_tensor_Wiki103 = attn_weight_loop(test_Wiki103_iter,best_GPT2_Wiki103)
在Amazon EC2实例上运行完此代码后,如何从计算机上检索并查看生成的attn_tensor_Wiki103
?
谢谢