Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
40b56c92
Commit
40b56c92
authored
Oct 23, 2022
by
AngelBottomless
Committed by
AUTOMATIC1111
Oct 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup some code
parent
b297cc33
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
11 deletions
+3
-11
modules/hypernetworks/hypernetwork.py
modules/hypernetworks/hypernetwork.py
+3
-11
No files found.
modules/hypernetworks/hypernetwork.py
View file @
40b56c92
...
...
@@ -16,6 +16,7 @@ from modules.textual_inversion import textual_inversion
from
modules.textual_inversion.learn_schedule
import
LearnRateScheduler
from
torch
import
einsum
from
collections
import
defaultdict
,
deque
from
statistics
import
stdev
,
mean
class
HypernetworkModule
(
torch
.
nn
.
Module
):
...
...
@@ -269,15 +270,6 @@ def stack_conds(conds):
return
torch
.
stack
(
conds
)
def
log_statistics
(
loss_info
:
dict
,
key
,
value
):
if
key
not
in
loss_info
:
loss_info
[
key
]
=
[
value
]
else
:
loss_info
[
key
]
.
append
(
value
)
if
len
(
loss_info
[
key
])
>
1024
:
loss_info
[
key
]
.
pop
(
0
)
def
statistics
(
data
):
total_information
=
f
"loss:{mean(data):.3f}"
+
u"
\u00B1
"
+
f
"({stdev(data)/ (len(data)**0.5):.3f})"
recent_data
=
data
[
-
32
:]
...
...
@@ -341,7 +333,7 @@ def train_hypernetwork(hypernetwork_name, learn_rate, batch_size, data_root, log
weight
.
requires_grad
=
True
size
=
len
(
ds
.
indexes
)
loss_dict
=
{}
loss_dict
=
defaultdict
(
lambda
:
deque
(
maxlen
=
1024
))
losses
=
torch
.
zeros
((
size
,))
previous_mean_loss
=
0
print
(
"Mean loss of {} elements"
.
format
(
size
))
...
...
@@ -383,7 +375,7 @@ def train_hypernetwork(hypernetwork_name, learn_rate, batch_size, data_root, log
losses
[
hypernetwork
.
step
%
losses
.
shape
[
0
]]
=
loss
.
item
()
for
entry
in
entries
:
lo
g_statistics
(
loss_dict
,
entry
.
filename
,
loss
.
item
())
lo
ss_dict
[
entry
.
filename
]
.
append
(
loss
.
item
())
optimizer
.
zero_grad
()
weights
[
0
]
.
grad
=
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment