上一页 1 ··· 683 684 685 686 687 688 689 690 691 ··· 851 下一页
摘要: ## 滑动均值和标准差 为了更好利用向量化来加速,滑动窗口使用`np.lib.stride_tricks.sliding_window_view(x, win)`提取,它会返回所有`x[i]`开头并且长度为`win`的数组的数组。 ```py def rolling(x, win): r = np. 阅读全文
posted @ 2023-07-12 15:43 绝不原创的飞龙 阅读(346) 评论(0) 推荐(0)
摘要: ``` score = ( class_weight + name_weight + children_comma_count + 1 + min(children_text_len // , 3) ) / (1 - link_density) ``` (1)正文元素,就是只在正文中可能出现的元素, 阅读全文
posted @ 2023-07-11 11:12 绝不原创的飞龙 阅读(41) 评论(0) 推荐(0)
摘要: ```py #!/usr/bin/env python from __future__ import print_function import logging import re import sys from lxml.etree import tounicode from lxml.etree 阅读全文
posted @ 2023-07-10 19:14 绝不原创的飞龙 阅读(101) 评论(0) 推荐(0)
摘要: ```py from lxml.html import tostring import lxml.html import re from .cleaners import normalize_spaces, clean_attributes from .encoding import get_enc 阅读全文
posted @ 2023-07-10 17:54 绝不原创的飞龙 阅读(38) 评论(0) 推荐(0)
摘要: ## `browser.py` ```py def open_in_browser(html): """ Open the HTML document in a web browser, saving it to a temporary file to open it. Note that this 阅读全文
posted @ 2023-07-10 17:48 绝不原创的飞龙 阅读(53) 评论(0) 推荐(0)
摘要: 注意力层: ``` 输入 -> LLQ -> @ -> /√ES -> softmax -> @ -> LLO -> Dropout -> 输出 | ↑ ↑ + > LLK + | | | + > LLV + ``` FFN 层: ``` 输入 -> LL1 -> GELU -> Dropout - 阅读全文
posted @ 2023-06-26 15:40 绝不原创的飞龙 阅读(43) 评论(0) 推荐(0)
摘要: ```py # Bert 编码器模块 # 由一个嵌入层和 NL 个 TF 层组成 class BERT(nn.Module): """ BERT model : Bidirectional Encoder Representations from Transformers. """ def __in 阅读全文
posted @ 2023-06-26 15:19 绝不原创的飞龙 阅读(54) 评论(0) 推荐(0)
摘要: ```py # PFF 层,基本相当于两个全连接 # 每个 TF 块中位于注意力层之后 class PositionwiseFeedForward(nn.Module): "Implements FFN equation." def __init__(self, d_model, d_ff, dro 阅读全文
posted @ 2023-06-26 14:40 绝不原创的飞龙 阅读(108) 评论(0) 推荐(0)
摘要: ```py # 注意力机制的具体模块 # 兼容单头和多头 class Attention(nn.Module): """ Compute 'Scaled Dot Product Attention """ # QKV 尺寸都是 BS * ML * ES # (或者多头情况下是 BS * HC * M 阅读全文
posted @ 2023-06-25 18:31 绝不原创的飞龙 阅读(119) 评论(0) 推荐(0)
摘要: ```py # 标记嵌入就是最普通的嵌入层 # 接受单词ID输出单词向量 # 直接转发给了`nn.Embedding` class TokenEmbedding(nn.Embedding): def __init__(self, vocab_size, embed_size=512): super( 阅读全文
posted @ 2023-06-25 17:15 绝不原创的飞龙 阅读(88) 评论(0) 推荐(0)
上一页 1 ··· 683 684 685 686 687 688 689 690 691 ··· 851 下一页