Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Error when computing derivative of function involving a complex matrix

オープン
#116 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
julia
領域
tooling

調査の方向性

issue にある最小の再現例から始め、src/tracked.jl の TrackedArray の処理を調べてから、src/derivatives/elementwise.jl の broadcast_mul パスを追います。失敗する Complex[1] * x のケースと、動作する Complex[x] のケースを比較します。失敗する例が TypeError なしで完了し、その微分を報告すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

For example consider the following minimal program:

function f4(x)
abs( (Complex[1] * x)[1] )
end

tp = InstructionTape()
at = ReverseDiff.TrackedReal(0.41992711708322633, 0, tp)
ot = f4(at)
ReverseDiff.seed!(ot)
ReverseDiff.reverse_pass!(tp)
println(deriv(at))

TypeError: in TrackedReal, in V, expected V<:Real, got Type{Complex{Float64}}

Stacktrace:
[1] ReverseDiff.TrackedArray(::Array{Complex{Float64},1}, ::Array{Int64,1}, ::Array{ReverseDiff.AbstractInstruction,1}) at /Users/wmoses/.julia/packages/ReverseDiff/qmgw8/src/tracked.jl:86
[2] track(::Array{Complex{Float64},1}, ::Type{Int64}, ::Array{ReverseDiff.AbstractInstruction,1}) at /Users/wmoses/.julia/packages/ReverseDiff/qmgw8/src/tracked.jl:387
[3] broadcast_mul(::Array{Complex,1}, ::TrackedReal{Float64,Int64,Nothing}, ::Type{Int64}) at /Users/wmoses/.julia/packages/ReverseDiff/qmgw8/src/derivatives/elementwise.jl:421
[4] broadcast at /Users/wmoses/.julia/packages/ReverseDiff/qmgw8/src/derivatives/elementwise.jl:343 [inlined]
[5] * at ./arraymath.jl:55 [inlined]
[6] f4(::TrackedReal{Float64,Int64,Nothing}) at ./In[165]:2
[7] top-level scope at In[165]:7

On the other hand the following succeeds:

function f4(x)
abs( (Complex[x])[1] )
end

tp = InstructionTape()
at = ReverseDiff.TrackedReal(0.41992711708322633, 0, tp)
ot = f4(at)
ReverseDiff.seed!(ot)
ReverseDiff.reverse_pass!(tp)
println(deriv(at))

主要言語
Julia
スター
397
フォーク
62
平均マージ
23時間 18分
マージ済み PR(30日)
16

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaDiff/ReverseDiff.jl のほかの issue

JuliaDiff/ReverseDiff.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。