Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .translate/state/jax_intro.md.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source-sha: 8d73de367a7f160dac777aa557f1c26069f84ea5
synced-at: "2026-04-12"
source-sha: 95378b8382b4dbd1cd3e0ffe0e152811894c357f
synced-at: "2026-04-13"
model: claude-sonnet-4-6
mode: UPDATE
section-count: 7
Expand Down
4 changes: 2 additions & 2 deletions .translate/state/numba.md.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source-sha: be6eeaee8db0c8bfea65b89d57ca8aecf7f96dff
synced-at: "2026-04-12"
source-sha: 95378b8382b4dbd1cd3e0ffe0e152811894c357f
synced-at: "2026-04-13"
model: claude-sonnet-4-6
mode: UPDATE
section-count: 5
Expand Down
4 changes: 2 additions & 2 deletions .translate/state/numpy_vs_numba_vs_jax.md.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source-sha: 94dd7d22385ec46d740db1fc2cddf05c29377594
synced-at: "2026-04-12"
source-sha: 95378b8382b4dbd1cd3e0ffe0e152811894c357f
synced-at: "2026-04-13"
model: claude-sonnet-4-6
mode: UPDATE
section-count: 3
Expand Down
19 changes: 7 additions & 12 deletions lectures/jax_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ translation:
Random numbers::Why explicit random state?::NumPy's approach: رویکرد NumPy
Random numbers::Why explicit random state?::JAX's approach: رویکرد JAX
JIT Compilation: کامپایل JIT
JIT Compilation::Evaluating a more complicated function: ارزیابی یک تابع پیچیده‌تر
JIT Compilation::Evaluating a more complicated function::With NumPy: با NumPy
JIT Compilation::Evaluating a more complicated function::With JAX: با JAX
JIT Compilation::Compiling the whole function: کامپایل کل تابع
JIT Compilation::With NumPy: با NumPy
JIT Compilation::With JAX: با JAX
JIT Compilation::Compiling the Whole Function: کامپایل کل تابع
JIT Compilation::How JIT compilation works: نحوه کار کامپایل JIT
JIT Compilation::Compiling non-pure functions: کامپایل توابع غیرخالص
Vectorization with `vmap`: برداری‌سازی با `vmap`
Expand Down Expand Up @@ -638,19 +637,15 @@ random_sum_jax(key)

ما قدرت کامپایلر JIT JAX را در ترکیب با سخت‌افزار موازی {ref}`در بالا <jax_speed>` مشاهده کردیم، هنگامی که `cos` را روی یک آرایه بزرگ اعمال کردیم.

بیایید همان کار را با یک تابع پیچیده‌تر امتحان کنیم.

### ارزیابی یک تابع پیچیده‌تر

تابع زیر را در نظر بگیرید
بیایید همان کار را با یک تابع پیچیده‌تر امتحان کنیم:

```{code-cell}
def f(x):
y = np.cos(2 * x**2) + np.sqrt(np.abs(x)) + 2 * np.sin(x**4) - x**2
return y
```

#### با NumPy
### با NumPy

ابتدا با NumPy امتحان خواهیم کرد

Expand All @@ -665,7 +660,7 @@ with qe.Timer():
y = f(x)
```

#### با JAX
### با JAX

اکنون بیایید دوباره با JAX امتحان کنیم.

Expand Down Expand Up @@ -701,7 +696,7 @@ with qe.Timer():
نتیجه مشابه مثال `cos` است --- JAX سریع‌تر است، به ویژه در
اجرای دوم پس از کامپایل JIT.

علاوه بر این، با JAX، ترفند دیگری در آستین داریم --- می‌توانیم *کل* تابع را JIT-کامپایل کنیم، نه فقط عملیات‌های منفرد.
علاوه بر این، با JAX، ترفند دیگری در آستین داریم --- می‌توانیم کل تابع را JIT-کامپایل کنیم، نه فقط عملیات‌های منفرد.

### کامپایل کل تابع

Expand Down
6 changes: 3 additions & 3 deletions lectures/numba.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ n = 10_000_000

with qe.Timer() as timer1:
# Time Python base version
x = qm(0.1, int(n))
x = qm(0.1, n)

```

Expand Down Expand Up @@ -158,7 +158,7 @@ qm_numba = jit(qm)
```{code-cell} ipython3
with qe.Timer() as timer2:
# Time jitted version
x = qm_numba(0.1, int(n))
x = qm_numba(0.1, n)
```

این یک افزایش سرعت قابل توجه است.
Expand All @@ -170,7 +170,7 @@ with qe.Timer() as timer2:
```{code-cell} ipython3
with qe.Timer() as timer3:
# Second run
x = qm_numba(0.1, int(n))
x = qm_numba(0.1, n)
```

در اینجا میزان افزایش سرعت نشان داده شده است:
Expand Down
Loading
Loading