摘要: model.train()的作用是启用 Batch Normalization 和 Dropout。 model.eval()的作用是不启用 Batch Normalization 和 Dropout。 训练流程: def train(model, optimizer, epoch, train_l 阅读全文
posted @ 2023-07-05 17:03 15375357604 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 1.pom文件中添加:<build> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> 阅读全文
posted @ 2023-06-26 18:14 15375357604 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 1. bert为什么attention除以根号下d 原因:因为点积的数量级增长很大,因此将 softmax 函数推向了梯度极小的区域。 案例: 在没有除以根号d时, raw_tensor = torch.tensor([[2.1,3.3,0.5,-2.7]]) torch.softmax(raw_t 阅读全文
posted @ 2023-06-16 14:06 15375357604 阅读(119) 评论(0) 推荐(0) 编辑
摘要: transformer中的模型分类: bert(自编码)、gpt(自回归)、bart(编码-解码) hidden_size (d) = num_attention_heads (m) * attention_head_size (a),也即 d=m*a, d为transformer模型输出的维度,这 阅读全文
posted @ 2023-06-16 09:58 15375357604 阅读(32) 评论(0) 推荐(0) 编辑
摘要: 因此,想要查看一个数组变量的地址,代码为: int arr[10]; cout << arr << endl; //注意,arr 之前无需 & 。 查看数组中第一个元素的地址: int arr[10]; cout << &arr[0] << endl; 递归:递归的过程是压栈的过程,递归结束,会出栈 阅读全文
posted @ 2023-06-05 19:41 15375357604 阅读(3) 评论(0) 推荐(0) 编辑
摘要: @,torch.matmul,torch.mm:矩阵相乘,第一个矩阵的列和第二个矩阵的行维度相同 *,torch.mul:矩阵对应元素相乘,所以两个矩阵维数相同,同维矩阵 torch.dot:一维的张量进行相乘再相加,结果是一个值 阅读全文
posted @ 2023-05-31 10:53 15375357604 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 静态方法 :需在类成员函数前面加上@staticmethod标记符,以表示下面的成员函数是静态函数。使用静态方法的好处是,不需要定义实例即可使用这个方法。另外,多个实例共享此静态方法。 class Person: grade=1 def __init__(self,name): self.name 阅读全文
posted @ 2023-05-30 15:35 15375357604 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 模型冻结部分层的训练方式: 第一步:在训练之前,将除了Embedding之外的层设置为param.requires_grad = False,如下所示: for name, param in model.named_parameters(): if "model.embed_tokens" not 阅读全文
posted @ 2023-05-29 17:52 15375357604 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 1.Controller @RequestMapping 注解用于绑定URI到具体处理器。 @RestController:Spring 4 新增注解,同样可以注解 Controller 类,相当于@Controller + @ResponseBody,主要是为了使 http 请求返回 json 或 阅读全文
posted @ 2023-05-29 10:28 15375357604 阅读(24) 评论(0) 推荐(0) 编辑
摘要: SparkSession spark = SparkSession.builder().appName("spark-item").config("spark.sql.warehouse.dir", warehouse_location).enableHiveSupport().config("sp 阅读全文
posted @ 2023-05-25 10:36 15375357604 阅读(11) 评论(0) 推荐(0) 编辑