Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vdl-submissions
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eberts
vdl-submissions
Commits
a9075bf0
Commit
a9075bf0
authored
1 year ago
by
Caina Rose Paul
Browse files
Options
Downloads
Patches
Plain Diff
Update exercise2.tex
parent
5a84cc0d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
exercises/exercise2/exercise2.tex
+50
-2
50 additions, 2 deletions
exercises/exercise2/exercise2.tex
with
50 additions
and
2 deletions
exercises/exercise2/exercise2.tex
+
50
−
2
View file @
a9075bf0
...
...
@@ -104,8 +104,56 @@ H_{\text{\small out}} = \frac{{H - k + 2p}}{s} + 1
Solution
\begin{equation*}
\hat
{
y
}
=S(z)
S(z
_
i)=
\frac
{
e
^{
z
_
i
}}{
\sum
^
N
_{
k=1
}
e
^{
z
_
k
}}
\begin{split}
\hat
{
y
}
&
= S(z)
\\
S(z
_
i)
&
=
\frac
{
e
^{
z
_
i
}}{
\sum
^
N
_{
k=1
}
e
^{
z
_
k
}}
\end{split}
\end{equation*}
For
\(
N
=
3
\)
, the softmax function is given by:
\[
S
(
z
_
1
)
=
\frac
{
e
^{
z
_
1
}}{
e
^{
z
_
1
}
+
e
^{
z
_
2
}
+
e
^{
z
_
3
}}
\]
Now, let's find the partial derivative with respect to
\(
z
_
j
\)
:
The detailed computation for
\(
j
=
1
\)
is as follows:
\[
\begin
{
aligned
}
\frac
{
\partial
S
(
z
_
1
)
}{
\partial
z
_
1
}
&
=
\frac
{
\partial
}{
\partial
z
_
1
}
\left
(
\frac
{
e
^{
z
_
1
}}{
e
^{
z
_
1
}
+
e
^{
z
_
2
}
+
e
^{
z
_
3
}}
\right
)
\\
&
=
\frac
{
e
^{
z
_
1
}
\cdot
(
e
^{
z
_
1
}
+
e
^{
z
_
2
}
+
e
^{
z
_
3
}
)
-
e
^{
z
_
1
}
\cdot
e
^{
z
_
1
}}{
(
e
^{
z
_
1
}
+
e
^{
z
_
2
}
+
e
^{
z
_
3
}
)
^
2
}
\\
&
=
\frac
{
e
^{
z
_
1
}}{
e
^{
z
_
1
}
+
e
^{
z
_
2
}
+
e
^{
z
_
3
}}
\cdot
\frac
{
e
^{
z
_
1
}
+
e
^{
z
_
2
}
+
e
^{
z
_
3
}
-
e
^{
z
_
1
}}{
e
^{
z
_
1
}
+
e
^{
z
_
2
}
+
e
^{
z
_
3
}}
\\
&
=
S
(
z
_
1
)
\cdot
\left
(
1
-
S
(
z
_
1
)
\right
)
\end
{
aligned
}
\]
\[
\begin
{
aligned
}
\frac
{
\partial
S
(
z
_
2
)
}{
\partial
z
_
1
}
&
=
\frac
{
\partial
}{
\partial
z
_
1
}
\left
(
\frac
{
e
^{
z
_
2
}}{
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}}
\right
)
\\
&
=
\frac
{
0
-
e
^{
z
_
2
}
\cdot
e
^{
z
_
1
}}{
\left
(
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}
\right
)
^
2
}
\\
&
=
-
\frac
{
e
^{
z
_
1
}
e
^{
z
_
2
}}{
\left
(
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}
\right
)
^
2
}
\\
&
=
-
\frac
{
e
^{
z
_
1
}}{
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}}
\cdot
\frac
{
e
^{
z
_
2
}}{
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}}
\\
&
=
-
S
(
z
_
1
)
S
(
z
_
2
)
\end
{
aligned
}
\]
\[
\begin
{
aligned
}
\frac
{
\partial
S
(
z
_
3
)
}{
\partial
z
_
1
}
&
=
\frac
{
\partial
}{
\partial
z
_
1
}
\left
(
\frac
{
e
^{
z
_
3
}}{
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}}
\right
)
\\
&
=
\frac
{
0
-
e
^{
z
_
3
}
\cdot
e
^{
z
_
1
}}{
\left
(
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}
\right
)
^
2
}
\\
&
=
-
\frac
{
e
^{
z
_
1
}
e
^{
z
_
3
}}{
\left
(
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}
\right
)
^
2
}
\\
&
=
-
\frac
{
e
^{
z
_
1
}}{
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}}
\cdot
\frac
{
e
^{
z
_
3
}}{
\sum
_{
k
=
1
}^
N e
^{
z
_
k
}}
\\
&
=
-
S
(
z
_
1
)
S
(
z
_
3
)
\end
{
aligned
}
\]
So from this, we can see a pattern
\begin{equation*}
\begin{aligned}
\frac
{
\partial
S(z
_
i)
}{
\partial
z
_
j
}
&
=
\begin{cases}
S(z
_
i)
\cdot
(1 - S(z
_
i)),
&
\text
{
if
}
i = j
\\
-S(z
_
i)S(z
_
j),
&
\text
{
if
}
i
\neq
j
\end{cases}
\end{aligned}
\end{equation*}
\subsection
{
Given
$
\hat
{
y
}
=
softmax
(
z
$
), a target vector
$
\hat
{
y
}
\in
\mathbb
{
R
}^
N
$
and the cross-entropy loss function defined as
\begin{equation*}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment