Julia是重度 LaTex符号的偏好的语言,这个已经深深融入Julia风格中。所以,有必要收藏一下LaTex符号表。
julia> for i ∈ 1:5 # /in
if i ∉ 2:3 # /notin
println(i)
end
end
1
4
5
julia> k = 4π # π : \pi
12.566370614359172
julia> num =rand()
julia> if num ≤ 0.5 println(num) end # ≤ : \leq
using Flux
layers = [Dense(10 ,5, σ), Dense(5,2), softmax] # σ: \sigma ->Sigmoid函数
m2(x) == (m2[:dec] ∘ m2[:enc])(x) # ∘ : \circ
"""
# Flux中的源代码
# https://github.com/FluxML/Flux.jl/blob/6476a314859f3e43fbf41c1857fd7b243cf07f21/src/losses/functions.jl#L26-L44
tversky_loss(ŷ, y; β = 0.7)
Return the [Tversky loss](https://arxiv.org/abs/1706.05721).
Used with imbalanced data to give more weight to false negatives.
Larger β weigh recall more than precision (by placing more emphasis on false negatives)
Calculated as:
1 - sum(|y .* ŷ| + 1) / (sum(y .* ŷ + β*(1 .- y) .* ŷ + (1 - β)*y .* (1 .- ŷ)) + 1)
"""
function tversky_loss(ŷ, y; β = ofeltype(ŷ, 0.7))
_check_sizes(ŷ, y)
#TODO add agg
num = sum(y .* ŷ) + 1
den = sum(y .* ŷ + β * (1 .- y) .* ŷ + (1 - β) * y .* (1 .- ŷ)) + 1
1 - num / den
end
1、如何输入这些符号?:先输入某个 LaTeX 符号(比如 \delta)再敲击 Tab 键.
2、如何查找这些符号?:打开Julia REPL环境,按下?切换到help模式:
help?> ∈
"∈" can be typed by \in<tab>
help?> δ
"δ" can be typed by \delta<tab>
julia> 123 ⊻ 234 #xor(x, y)
145
help?> ⊻
"⊻" can be typed by \xor<tab>
julia> 123 ⊽ 124
-128
help?> ⊽
"⊽" can be typed by \nor<tab>
search: ⊽
nor(x, y)
⊽(x, y)
julia> ⊗(A,B) = kron(A,B)
⊗ (generic function with 1 method)
help?> ⊗
"⊗" can be typed by \otimes<tab>
julia> ∑(x,y)= x^2 + y^2
∑ (generic function with 1 method)
help?> ∑
"∑" can be typed by \sum<tab>
julia> ϵ = 0.00001
1.0e-5
help?> ϵ
"ϵ" can be typed by \epsilon<tab>
help?> ŷ
"ŷ" can be typed by y\hat<tab>
help?> ≈
"≈" can be typed by \approx<tab>
julia> gelu(x) = 0.5x * (1 + tanh(√(2/π) * (x + 0.044715x^3)))
gelu (generic function with 1 method)
help?> √
"√" can be typed by \sqrt<tab>
julia> selu(x) = λ * (x ≥ 0 ? x : α * (exp(x) - 1))
selu (generic function with 1 method)
help?> λ
"λ" can be typed by \lambda<tab>
help?> α
"α" can be typed by \alpha<tab>
help?> η # 往往学习率用这个符号表示
"η" can be typed by \eta<tab>
3、附表