Measure Zero


  • About

  • Quotes

  • Notes

  • Sitemap

  • Search

Minimum cut 的一个应用

2023-01-14 | ~ | Machine Learning

同事看表格检测的文章

  • Tensmeyer, C., Morariu, V. I., Price, B., Cohen, S., & Martinez, T. (2019, September). Deep splitting and merging for table structure decomposition. In 2019 International Conference on Document Analysis and Recognition (ICDAR) (pp. 114-121). IEEE.

中的 Split Model 的 Inference 那节. 文章采用的表格检测分为两步, 先划若干条竖直线和水平线将图像分割为许多单元格, 再合并单元格得到表格.

Read more »

MLFlow 简介

2023-01-06 | ~ | Machine Learning

管理深度学习实验

可以参考 这个问题 下的回答. 主要需要保存每次实验的

  • 代码 (Git 提交记录)
  • 数据 (路径), 模型
  • 超参数, 指标
  • 日志

保证实验结果好找, 便于复现实验. 这类工具 (满足上述部分功能) 有很多, 比如 TensorBoard; 自己写也可以.

介绍 MLflow

MLflow 是开源的机器学习工作流 (workflow) 管理平台, 提供了 Python, R, Java, REST API 等多种接口. 它是 Spark 团队 (他们还创建了 Databricks 公司) 2018 年的新作, 现在已经到 2.1 版本了.

With origins in academia and the open source community, Databricks was founded in 2013 by the original creators of Apache Spark™, Delta Lake and MLflow.

如果只是管理实验, 那每个人在本地上自己操作就行. MLflow 提供了中心化的管理, 有助于多人协作, 管理模型生命周期. 包含如下四个组件 (最主要的是 tracking 和 model registry).

Read more »

Huggingface Transformers Trainer as a general PyTorch trainer

2023-01-04 | ~ | Machine Learning

受 这篇 启发, 自定义 Huggingface Transformers Trainer 做通用训练器.

模型定义照常.

import torch.nn as nn

class Model(nn.Module):
    def forward(self, inputs):
        ...
        return logits

自定义损失函数. 损失函数要么写在模型的 forward 里 (Huggingface 的写法), 要么继承 Trainer 类, 覆写 compute_loss.

import transformers

class MyTrainer(transformers.Trainer):
    def compute_loss(self, model, inputs, return_outputs=False):
        labels = inputs.pop('labels')
        logits = model(**inputs)
        # loss_fct = nn.CrossEntropyLoss()
        loss_fct = nn.BCEWithLogitsLoss()
        loss = loss_fct(logits, labels)
        # TODO: tested only with `return_outputs=False`
        return (loss, {'logits': logits}) if return_outputs else loss
Read more »

Notes on Distributed Data

2023-01-01 | ~ | Tech
  • Kleppmann, M. (2017). Designing data-intensive applications: The big ideas behind reliable, scalable, and maintainable systems. “ O’Reilly Media, Inc.”.

There are various reasons why you might want to distribute a database across multiple machines:

  • Scalability
  • Fault tolerance/high availability
  • Latency

Replication

Replication means keeping a copy of the same data on multiple machines that are connected via a network. All of the difficulty in replication lies in handling changes to replicated data.

  • 使数据和用户地理邻近 (减少延迟)
  • 系统部分故障也能继续工作 (提高可用性)
  • 横向扩展处理读取请求 (提高读取吞吐量)

In this chapter we will assume that your dataset is so small that each machine can hold a copy of the entire dataset.

Read more »

GPT-1 到 ChatGPT 简介

2022-12-24 | ~ | Machine Learning

总体时间线参考 这里.

GPT-1~3

GPT-1

Our system works in two stages; first we train a transformer model on a very large amount of data in an unsupervised manner — using language modeling as a training signal — then we fine-tune this model on much smaller supervised datasets to help it solve specific tasks.

We trained a 12-layer decoder-only transformer with masked self-attention heads (768 dimensional states and 12 attention heads).

GPT 全称 generative pre-training, 就是预训练 + 微调. 时间顺序从前到后依次是, GPT-1, BERT, GPT-2.

来自 BERT 论文

Read more »

[Walkthrough] Install and set up Redis

2022-12-19 | ~ 2023-01-04 | Tech

Check system info.

cat /etc/os-release

Follow a walkthrough listed here. The below works on CentOS 7.

Read more »

Atypical: Season 4 Episode 1 Transcript

2022-12-18 | ~ | Language

一时兴起的听写, 不保证对. 听了个开头 (然后看完了), Sam 的台词最容易听.

Read more »

正则灾难性回溯与防御方法

2022-12-10 | ~ | Tech

灾难性回溯

考虑用正则表达式 (x+x+)+y 匹配字符串 xxxxxxxxxxy (10 个 x). 显然正则可以改写为 xx+y 或者 x{2,}y, 但先不管这点, 该例旨在展示匹配机制.

  • 第一个 x+ 匹配 10 个 x, 第二个 x+ 没匹配上; 于是第一个 x+ 回溯 到匹配 9 个 x, 第二个 x+ 匹配一个 x. 至此 group 1 x+x+ 完成了一次匹配.
  • Group 1 尝试重复, 但失败了, 于是 (x+x+)+ 完成了一次匹配. 接下来匹配 y, 完成匹配.

删除字符串结尾的 y 使得正则匹配失败会导致 灾难性回溯 (catastrophic backtracking).

Read more »

RabbitMQ 消息确认机制

2022-11-23 | ~ | Tech

生产者先把消息发到 exchange (很多个), exchange 决定把消息分发到哪些 queue (很多个), 再从 queue 发到消费者.

确认机制分为两部分, exchange 确认收到 publisher 的消息, consumer 确认收到 queue 的消息. 来自官方文档 Consumer Acknowledgements and Publisher Confirms — RabbitMQ

Read more »

《看不见的女性》笔记

2022-11-13 | ~ | Reading
  • 卡罗琳·克里亚多·佩雷斯. (2022, Aug). 看不见的女性. 新星出版社.

原书还有副标题, Invisible Women: Data Bias in a World Designed for Men. 书中陈列了大量数据和例子展示这一点.

论及性别数据缺口, 最重要的观点之一是它通常不带恶意, 甚至并非有意. 事实恰恰相反: 性别数据缺口完全是一种存在了数千年的思考方式的产物, 因此也可说源于不思考. 双重的不思考: 男人不言而喻, 女人不被提及. 因为当我们说到人类, 总的来说, 我们指的是男人.

三个主题: 女性的身体, 女性无偿看护的负担, 和男性对女性的暴力.

将人类 (human) 默认为男性, “不加说明就是男性”. 比如众所周知, 很多职业需要在前面额外加个 “女” 以示区分, 以及很多语言单词里也有默认性别. 有趣的是, Unicode 将 “跑步者” emoji 加入编码后, 大多数平台使用的图标是男性跑步者, 直到 2016 年 Unicode 区分了两性跑步者. 虽然这些平台想设计出 “中性” 的跑者形象, 但多数人还是会把它看作男性. (国足指男国家队.)

影视作品中女性出现比例也显著小于男性: 儿童电视角色中女性非人类角色, 电影主演, 出场时间 (只有当主角是女性时, 两性出场频率才大体一样, 而不是女性更多) 等. 不平衡还表现在雕像, 钞票, 新闻媒体报道上等.

这种完全由男性主导的文化带来的后果是, 男性的经验和视角被视为普遍, 而女性的被视为小众.

Read more »
1 … 3 4 5 … 18
Shiina

Shiina

知乎 豆瓣 bangumi Instagram Weibo
Creative Commons
RSS
© 2019 - 2026   Shiina   CC BY-NC-ND 4.0
RSS  
Powered by Jekyll
 
Theme NexT.Mist