在 Julia 中,使用@edit
REPL 中的宏调用函数将打开编辑器并将光标放在定义方法的行上。所以,这样做:
julia> @edit 1 + 1
Run Code Online (Sandbox Code Playgroud)
跳转到julia/base/int.jl
并将光标放在该行上:
(+)(x::T, y::T) where {T<:BitInteger} = add_int(x, y)
Run Code Online (Sandbox Code Playgroud)
一样的函数形式:edit(+, (Int, Int))
Python 中是否有与 Python REPL 相同的装饰器/函数?
在 Keras 中,为什么input_shape
当作为参数传递给层时不包括批处理维度,Dense
但在input_shape
传递给build
模型的方法时包含批处理维度?
import tensorflow as tf
from tensorflow.keras.layers import Dense
if __name__ == "__main__":
model1 = tf.keras.Sequential([Dense(1, input_shape=[10])])
model1.summary()
model2 = tf.keras.Sequential([Dense(1)])
model2.build(input_shape=[None, 10]) # why [None, 10] and not [10]?
model2.summary()
Run Code Online (Sandbox Code Playgroud)
这是 API 设计的有意识选择吗?如果是,为什么?
Tensorflow提供参差不齐的张量(https://www.tensorflow.org/guide/ragged_tensor)。但是,PyTorch不提供这种数据结构。有没有在PyTorch中构造类似内容的解决方法?
import numpy as np
x = np.array([[0], [0, 1]])
print(x) # [list([0]) list([0, 1])]
import tensorflow as tf
x = tf.ragged.constant([[0], [0, 1]])
print(x) # <tf.RaggedTensor [[0], [0, 1]]>
import torch
# x = torch.Tensor([[0], [0, 1]]) # ValueError
Run Code Online (Sandbox Code Playgroud) 一个pip install
有所有额外功能的怎么办?我知道做这样的事情:
pip install -e .[docs,tests,others]
Run Code Online (Sandbox Code Playgroud)
是一种选择。但是,是否可以执行以下操作:
pip install -e .[all]
Run Code Online (Sandbox Code Playgroud)
这个问题类似于setup.py/setup.cfg install all extras。但是,那里的答案要求setup.cfg
编辑该文件。是否有可能做到这一点无需修改setup.py
或setup.cfg
?
在编写机器学习模型时,我发现自己需要计算指标,或者在回调中运行额外的前向传递以实现可视化目的。在PyTorch中,我使用 执行此操作torch.no_grad()
,这可以防止计算梯度,因此这些操作不会影响优化。
model(x)
是可能的。但是,也可以说model.predict(x)
,这似乎也援引了call
. 两者有区别吗?评估
bitstring(Int8(3))
Run Code Online (Sandbox Code Playgroud)
返回"00000011"
。Julia 中是否有内置函数来执行将位串解析为整数的逆运算?
python ×5
julia ×2
keras ×2
pytorch ×2
tensorflow ×2
parsing ×1
pip ×1
ragged ×1
setuptools ×1