108 Matching Annotations
  1. Dec 2021
    1. output tokens

      I have a question. How do we get the output tokens? Are the output tokens similar to the input tokens?

    2. 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?

  2. Jun 2021
  3. 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.

    1. 两个远程系统之间的复制

      Note: scp is able to copy file from a remote server to another one.

  4. Feb 2021
    1. Regression Loss Functions

      回归损失函数

    2. 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.

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

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

      没有看懂

  6. 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. As of Python 3.6, f-strings are a great new way to format strings.

      Python 3.6 之后推出的 f-strings 语法

    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

    1. A location into which the result is stored.

      out 参数是用来存放结果的 这样可以达到就地计算的效果

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

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

    2. line.strip()

      去掉字符串头和尾的空格

    3. # A recursive generator that generates Tree leaves in in-order.

      用生成器来写中序遍历

    4. Any function containing a yield keyword is a generator function;

      函数体里包含 yield 关键字的函数都是生成器函数

    5. Generators

      生成器

    6. if expression is creating a tuple, it must be surrounded with parentheses.

      如果表达式创建了一个元组,那么必须被圆括号包裹.

    7. list comprehensions

      List Comprehensions 列表推导

      Generator Expressions 生成器表达式

    8. An object is called iterable if you can get an iterator for it.

      言外之意就是,如果调用 iter 之后没有报 TypeError, 说明该对象是可迭代的(iterable)

    9. An iterator is an object representing a stream of data;

      迭代器是一个代表数据流的对象

    1. 两个向量的外积,又叫向量积、叉乘等

      叉乘代表外积

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

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

    1. *

      * 应该表示当前文件夹内的文件, 类似于 ls

    2. begins with a special symbol: #. This marks the line as a comment

      以#开头的代码表示这行代码被注释掉了,这点跟 Python 一致。

    1. Note that to make a file executable, you must set the eXecutable bit, and for a shell script, the Readable bit must also be set:

      这句话没懂

    2. Shell Scripting Tutorial

      shell 编程教程

    1. Trajectory

      trajectory 轨迹

      the path that a object follows as it moves

    1. robotics researchers

      机器人研究人员

    2. Optical flow

      the distribution of apparent velocities of movement of brightness pattern in an image.

    1. Used by convention to avoid naming conflicts with Python keywords.

      var_ 主要用来避免与关键字冲突

    2. meant as a hint to the programmer only.

      _var 这种单下划线对于解释器没有实际作用.程序员之间表示内部使用的公用做法

    1. torch.argmax(input, dim, keepdim=False) → LongTensor

      注意: dim 参数 0 表示列;1 表示行 .argmax() 跟 .max().indices 差不多

    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. Tensor底层一维数组元素的存储顺序与Tensor按行优先一维展开的元素顺序是否一致。

      作者的解释很准确。

    4. 执行 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.

    5. t2 = t.transpose(0,1)

      等同于 t2 = t.t()

    6. torch.view等方法操作需要连续的Tensor

      torch.view 为什么需要连续的 (contiguous) 的 Tensor

    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 用步长指定样本个数
    2. Number of samples to generate.

      参数 num 表示待生成的样本个数,默认值是50

    3. numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0

      endpoint 的默认值是 True,即默认包含 stop 。

    1. The angle by which the start of the pie is rotated, counterclockwise from the x-axis.

      x轴逆时针旋转的角度

    1. The second is a “throwaway” variable that we don’t need just yet, denoted with an underscore.

      用下划线来表示没有用的变量

    1. If <key> is not found, it returns None

      .get(key) 如果键存在返回相应的值,否则返回 None

    2. The len() function returns the number of key-value pairs in a dictionary

      len 函数返回字典中键值对的个数

    3. the in and not in operators

      用来检查值是否在字典中。

    4. key values are simple strings

      当键值都是简单字符串的时候,键可以不用引号包裹。

    5. Restrictions on Dictionary Values

      Python对 dict 的值没有限制, 可以是任意类型(包括可变类型和自定义对象)

    6. it is not quite correct to say an object must be immutable to be used as a dictionary key.

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

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

    7. Restrictions on Dictionary Keys#

      dict 键值的限制:

      1. 键不能重复
      2. 键必须是不可变量(列表、字典不可以)
    8. a dictionary key must be of a type that is immutable.

      dict 键必须是不可修改的(immutable)

    9. the values contained in the dictionary don’t need to be the same type.

      dict 键和值的类型不必相同

    10. on the fly

      不懂确切的中文意思, 感觉是 快速初始化 的意思

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

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

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

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

    13. If you refer to a key that is not in the dictionary, Python raises an exception:

      https://realpython.com/python-defaultdict 可以参看这篇文章. defaultdict 可以处理 missing key 的情况.

    14. Dictionary elements are not accessed by numerical index

      注意: Python 中字典不能通过数字下标访问元素.

    15. A list of tuples works well for this:

      可以通过元素列表初始化字典.

      dd = dict([('a',1),('b',2)])
      
    16. Dictionaries and lists share the following characteristics:

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

      1. 可以修改的
      2. 动态变化,支持增加和缩减.
      3. 支持嵌套. 列表中可以嵌套另一个列表, 字典可以包含另一个字典.字典也可以包含列表.
    17. Dictionaries differ from lists primarily in how elements are accessed:

      Python 中字典与列表的不同点:

      1. 列表通过下标访问元素
      2. 字典用过键值访问元素
    1. 这篇文章主要介绍了 Python 中字典处理缺省键值的方法。

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

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

    2. the instance behaves like a standard dictionary.

      如果初始化 defaultdict 没有参数, 该变量蜕变成一个标准 dict。

    3. The first argument to the Python defaultdict type must be a callable that takes no arguments and returns a value.

      不接受形参,并且返回一个值。

    4. Using the Python defaultdict Type for Handling Missing Keys

      用 Python 的 defaultdict 处理不存在的键

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

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

    5. not to call it using the parentheses at initialization time.

      注意.default_factory 赋值的时候一定不要带括号。

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

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

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

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

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

    8. four available ways to handle missing keys

      处理缺省键的四种方式:

      1. .setdefault()
      2. .get()
      3. key in dict
      4. try and except
    9. 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 会自动创建这个键然后生成一个默认值

    10. subclass collections.UserDict

      我的问题是: 为什么要继承 collections.UserDict?

    11. Decide when and why to use a Python defaultdict rather than a standard dict

      这句子不错

      Decide when and why to use a Python defaultdict rather than a standard dict.

    12. Emulating the Python defaultdict Type

      模仿 Python defatultdict 类型

    13. augmented assignment operator

      augemented assignment operators In Chinese: 增强赋值运算符

    14. Sets are collections of unique objects,

      Python 中的 set 是单一对象的集合,不存在重复项。 与 C++ 的 set , unordered_set 类似

    15. for large datasets, it can also be a lot faster and more efficient.

      defaultdict 速度和效率往往好于 dict

    16. Diving Deeper Into defaultdict

      深入分析 defaultdict

    17. When and why to use a Python defaultdict rather than a regular dict

      何时以及为什么用 Python 的 defaultdict 而不是常规的 dict

    1. Note that __missing__() is not called for any operations besides __getitem__().

      missing() 不会被除 getitem() 之外的其他操作调用。

    1. 将RGB分量转化成灰度图像

      三通道转换成双通道的灰度图像?

    2. Gamma校正

      这里的 x y 代表什么?

      $$Y(x,y) = I(x,y)^\gamma$$

    1. 目标检测

      Object Detection

    2. 大概过程

      大概过程:

      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 的概率是多大?