109 Matching Annotations
  1. Sep 2025
    1. In this example we first initialize an ArenaAllocator with a child allocator, in this case the page allocator.

      If I wrote this, I would say

      In this example we first initialize an ArenaAllocator with a child allocator, it's the page allocator in this case.

  2. Dec 2021
    1. An attention function can be described as mapping a query and a set of key-value pairs to an output, where the query, keys, values, and output are all vectors.

      What does this mean?

  3. Jun 2021
  4. Mar 2021
    1. PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { m.def("forward", &lltm_forward, "LLTM forward"); m.def("backward", &lltm_backward, "LLTM backward"); }

      For functions, you can simply attach the function using .def directly.

  5. Feb 2021
    1. Neural network models learn a mapping from inputs to outputs from examples and the choice of loss function must match the framing of the specific predictive modeling problem, such as classification or regression. Further, the configuration of the output layer must also be appropriate for the chosen loss function.

      神经网络模型根据例子学习输入到输出的映射,损失函数的选择必须跟特定预测模型相匹配,比如分类和回归。而且,输出层必须与使用的损失函数配置恰当。

  6. Jan 2021
    1. 如果回归的是坐标,那么在计算损失时,大尺寸bbox的坐标误差占的比重可能就会比小尺寸bbox之间的坐标误差大得多,从而使得模型更偏向于学习大bbox,从而导致小目标的检测效果不佳

      没有看懂

  7. Nov 2020
    1. 可以认为 π k \pi_k πk​就是每个分量 N ( x ∣ μ k , Σ k ) \mathcal{N}(\boldsymbol{x}|\boldsymbol{\mu}_k, \boldsymbol{\Sigma}_k) N(x∣μk​,Σk​)的权重。

      有的书称为责任

    1. The behaviour of the argument function is extended by the decorator without actually modifying it.

      需要修饰的函数被装饰器(decorator)扩展,且不用修改原函数.

    1. zip -r myfile.zip ./filename

      把filename 压缩成 myfile.zip

      unzip -d /home/file myfile.zip

      把myfile.zip 压缩到 home/file 目录下

      zip -d myfile.zip smart.txt

      删除 myfile.zip 中的 smart.txt

      zip -m myfile.zip add.txt

      往 myfile.zip 中加 add.txt

  8. Oct 2020
    1. 和 Python 里的字符串和列表切片不同,你不能在 start, stop 或者 step 这些参数中使用负数。:

      通过 itertools.islice() 可以实现 set dict 的切片操作。

    1. key 形参用来指定在进行比较前要在每个列表元素上调用的函数

      与 C++ 不同,key 形参用来指定进行比较前在每个列表元素上调用的函数。

    1. torch.randint

      Recap: torch.randint(low=0, high, size) 生成由在 [low, high] 之间随机整数的组成的 tensor,大小是 size 。

      • low 下限,可缺省。默认值是0。如果参数 high 是负数就不能缺省。
      • high 上限不能缺省。
      • size 类型是 tuple 掺入参数的时候无比要加括号!
    1. 可能在返回Tensor底层数据中使用了新的内存

      刚才测试了一下

      如果直接调用 t3=t.contiguous().view(-1)

      t3 和 t 共享同一块内存,即没有使用新的内存。

    2. 需要先使用 t2 的 stride (1, 4) 转换到 t2 的结构,再基于 t2 的结构使用 stride (1,) 转换为形状为 (12,)的 b 。但这不是view工作的方式,view 仅在底层数组上使用指定的形状进行变形,即使 view 不报错,它返回的数据是

      作者的意思大概是:.view() 操作需要 stride 和 size 相匹配。

      但是 .transpose() 只修改了 stride,这导致 stride 和 size 不匹配 (compatible) 所以无法进行 .view() 操作。

    3. 执行 t2.view(-1)

      报错

      view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

    1. numpy.arange([start, ]stop, [step, ]dtype=None

      arange 函数签名

      start 可以缺省,默认值是 0.

      stop 不能缺省, 若是整数则输出的 ndarray 不包括 stop.

    1. bbool or None, optional

      参数 b 用来表示是否展示刻度线。

      但是当传入键值参数之后,matplotlib自动将 b 置为 True (也就是展示刻度线)。

      如果 b 是 None 并且 没有键值参数传入的时候(也就是空参), 才不展示刻度线。

      对第二句话有疑问,刚才做过测试 .grid() 和 .grid(True) 的作用相同,都会画刻度线。

    1. That function takes a tuple to specify the size of the output,

      numpy.random.rand() 接收元组作为参数,表示输出的 numpy.ndarray 的形状。

      这和 numpy.ones numpy.zeros 一致

    1. Similar to linspace, but uses a step size (instead of the number of samples).

      linspace 和 arange 的区别是:

      • linspace 用参数 num 指定样本个数
      • arange 用步长指定样本个数
    1. it is not quite correct to say an object must be immutable to be used as a dictionary key.

      一个对象必须是不可变的才能用作 dict 的键。

      这句话不是很准确。 严谨的说,一个对象必须是可哈希(hashable) 的,才可以用作 dict 的键。

    2. Python does guarantee that the order of items in a dictionary is preserved.

      尽管 Python 中访问字典元素与顺序无关, 但是 Python 会保存字典中元素定义的顺序(Python 3.7 引入的新特性).

    3. they have nothing to do with the order of the items in the dictionary.

      Python 中字典同样可以通过数字来访问,但是与列表不同的是,数字大小与元素的顺序没有关系.

    4. Dictionaries and lists share the following characteristics:

      Python 中字典和列表的相同点是:

      1. 可以修改的
      2. 动态变化,支持增加和缩减.
      3. 支持嵌套. 列表中可以嵌套另一个列表, 字典可以包含另一个字典.字典也可以包含列表.
    1. 这篇文章主要介绍了 Python 中字典处理缺省键值的方法。

      引入了一个新的数据类型 defaultdict,并介绍了它访问和修改不存在键值时的机制。

      主要是重写了 .missing__() 使得在通过 subscription operation 访问修改缺省键值时自动调用该方法,从而避免了dict 的 TypeError。

    2. Using the Python defaultdict Type for Handling Missing Keys

      用 Python 的 defaultdict 处理不存在的键

      想要学习 defaultdict 的原因: 看到 up 主在实现 DFS 的时候用到了这个语法 code

      可以看到的是作者用到了对缺省键的访问操作。

    3. the dictionary assigns it the default value that results from calling list().

      当我们访问不存在键的时候,defaultdict 会自动将调用 default_factory 的值赋给该键。

    4. if you call .setdefault() on an existing key, then the call won’t have any effect on the dictionary.

      如果对已存在的键调用 setdefault ,不会修改原值。

      如果是缺省键,就会创建新的键值对。

    5. if you try to access or modify a missing key, then defaultdict will automatically create the key and generate a default value for it.

      如果你想要访问或者修改一个缺省键值, defaultdict 会自动创建这个键然后生成一个默认值

    1. 大概过程

      大概过程:

      1. 灰度化
      2. 采用 Gamma 校正法对输入图像归一化
      3. 计算图像每个像素的梯度(包括大小和方向)
      4. 将图像分块
      5. 统计每块的梯度直方图(不同梯度的个数)
      6. 没几个块组成一个大块 steps
    1. If we know the ball lands at a position ccc after the second drop, what is the probability that the previous position was aaa?

      如果我们知道球第二次落在 c 位置,那么之前的位置是 a 的概率是多大?