使用云服务器的环境和第三方库的准备

以colab为例,介绍导入多个安装包的通用流程,基本上包含了所有需要的库

1.导入谷歌硬盘作为运行地址

from google.colab import drive
drive.mount('/content/drive')

2.用linux命令安装requirements.txt中的库

%cd drive/MyDrive/BDCI_little_sample  #进入到当前执行环境路径
%ls #查看当前路径下的所有文件有没有requirements.txt
!pip install -r requirements.txt

3.导入库函数

import numpy as np
import pandas as pd
import time
import math
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import f1_score
from torch.optim import Adam, SGD, AdamW
from transformers import get_linear_schedule_with_warmup, get_cosine_schedule_with_warmup, DataCollatorWithPadding
from transformers import BertTokenizer,AutoModel,AdamW,AutoConfig, AutoModelForSequenceClassification, AutoTokenizer
import torch
from torch.utils.data import Dataset, DataLoader
from torch.optim import lr_scheduler
import torch.nn.functional as F
from tqdm import tqdm
import copy
import torch.nn as nn
import os
import json
import gc
import random

你可能感兴趣的:(模型训练与比赛技巧,ipython)