Other

项目介绍

FluxML/Zygote.jl 是一个托管在 GitHub 上的开源项目,主要使用 Julia 编写,采用 Other 许可证,目前获得 1.6k 个 Star、221 次 Fork。

仓库全名
FluxML/Zygote.jl
开源许可证
Other
Star 数
1.6k
Fork 数
221
未关闭 Issue
228

README 摘要

] add Zygote Zygote provides source-to-source automatic differentiation (AD) in Julia, and is the next-gen AD system for the Flux differentiable programming framework. For more details and benchmarks of Zygote's technique, see our paper. You may want to check out Flux for more interesting examples of Zygote usage; the documentation here focuses on internals and advanced AD usage. Zygote supports Julia 1.10 onwards…

完整内容见 GitHub 原始 README 或本页 。

常见问题

Zygote.jl 用什么语言开发?

主要使用 Julia 编写,采用 Other 许可证,目前有 1.6k 个 Star。

Zygote.jl 可以免费商用吗?

仓库标注的许可证为 Other,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 Zygote.jl 的源码?

可以直接克隆仓库:git clone https://github.com/FluxML/Zygote.jl.git,默认分支为 master;安装与运行步骤见仓库 README。

Zygote.jl 最近还在维护吗?

仓库最近一次更新为 4 天前,当前有 228 个未关闭 Issue;Star 数为 1.6k,可作为社区活跃度的参考。

README

CI Testing Coverage Dev Docs

] add Zygote

Zygote provides source-to-source automatic differentiation (AD) in Julia, and is the next-gen AD system for the Flux differentiable programming framework. For more details and benchmarks of Zygote’s technique, see our paper. You may want to check out Flux for more interesting examples of Zygote usage; the documentation here focuses on internals and advanced AD usage.

Zygote supports Julia 1.10 onwards.

julia> using Zygote

julia> f(x) = 5x + 3

julia> f(10), f'(10)
(53, 5.0)

julia> @code_llvm f'(10)
define i64 @"julia_#625_38792"(i64) {
top:
  ret i64 5
}

“Source-to-source” means that Zygote hooks into Julia’s compiler, and generates the backwards pass for you – as if you had written it by hand.

Zygote supports the flexibility and dynamism of the Julia language, including control flow, recursion, closures, structs, dictionaries, and more. Mutation and exception handling are currently not supported.

julia> fs = Dict("sin" => sin, "cos" => cos, "tan" => tan);

julia> gradient(x -> fs[readline()](x), 1)
sin
0.5403023058681398

Zygote benefits from using the ChainRules.jl ruleset. Custom gradients can be defined by extending the ChainRulesCore.jl’s rrule:

julia> using ChainRulesCore

julia> add(a, b) = a + b

julia> function ChainRulesCore.rrule(::typeof(add), a, b)
           add_pb(dy) = (NoTangent(), dy, dy)
           return add(a, b), add_pb
       end

To support large machine learning models with many parameters, Zygote can differentiate whole models with respect to their (possibly nested) structure of parameters, by passing them explicitly as arguments.

julia> using Zygote

julia> model = (W = rand(2, 3), b = rand(2));

julia> predict(model, x) = model.W * x .+ model.b;

julia> g = gradient(m -> sum(predict(m, [1, 2, 3])), model)[1]
(W = [1.0 2.0 3.0; 1.0 2.0 3.0], b = [1.0, 1.0])

[!WARNING] Zygote also has a legacy implicit-parameters interface, in which the parameters of interest are collected in a Zygote.Params object and the gradients returned in a dictionary-like Grads object. This interface is deprecated and will be removed in a future release; use the explicit style shown above instead.

评论

暂无评论