Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kaggle Phytoplankton
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
Messaoudi Rayan
Kaggle Phytoplankton
Commits
c1356bff
Commit
c1356bff
authored
2 years ago
by
Yandi
Browse files
Options
Downloads
Patches
Plain Diff
[Normalizing the input]
parent
0615e610
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Master into main
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
create_submission.py
+0
-1
0 additions, 1 deletion
create_submission.py
dataloader.py
+1
-0
1 addition, 0 deletions
dataloader.py
main.py
+10
-5
10 additions, 5 deletions
main.py
train.py
+10
-7
10 additions, 7 deletions
train.py
with
21 additions
and
13 deletions
create_submission.py
+
0
−
1
View file @
c1356bff
...
...
@@ -71,7 +71,6 @@ def create_submission(model, transform, device):
with
torch
.
no_grad
():
for
X
in
tqdm
.
tqdm
(
test_loader
):
X
=
X
.
to
(
device
)
print
(
X
.
shape
)
#############################################
# This is where you inject your knowledge
# About your model
...
...
This diff is collapsed.
Click to expand it.
dataloader.py
+
1
−
0
View file @
c1356bff
...
...
@@ -121,6 +121,7 @@ def get_dataloaders(
target_transform
=
valid_target_transform
,
num_days
=
num_days
,
)
# The sum of the two folds are not expected to be exactly of
# max_num_samples
logging
.
info
(
f
"
- The train fold has
{
len
(
train_dataset
)
}
samples
"
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
10
−
5
View file @
c1356bff
...
...
@@ -55,9 +55,9 @@ if __name__ == "__main__":
#network = network.build_network(cfg, 18)
network
=
nn
.
Sequential
(
nn
.
Linear
(
14
,
8
,
Fals
e
),
nn
.
Linear
(
14
,
35
,
Tru
e
),
nn
.
ReLU
(),
nn
.
Linear
(
8
,
35
,
True
),
nn
.
Linear
(
35
,
35
,
True
),
nn
.
ReLU
(),
nn
.
Linear
(
35
,
35
,
True
),
nn
.
ReLU
(),
...
...
@@ -67,18 +67,23 @@ if __name__ == "__main__":
nn
.
ReLU
(),
nn
.
Linear
(
35
,
35
,
True
),
nn
.
ReLU
(),
nn
.
Linear
(
35
,
35
,
True
),
nn
.
ReLU
(),
nn
.
Linear
(
35
,
1
,
True
),
nn
.
ReLU
()
)
"""
def init_xavier(module):
if type(module)==nn.Linear:
nn
.
init
.
xavier_uniform_
(
module
.
weight
)
nn.init.constant_(module.weight,1)
"""
network
=
network
.
to
(
device
)
"""
for
param in list(network.parameters())
:
param = 1
for
layer in network
:
layer.apply(init_xavier)
"""
f_loss
=
losses
.
RMSLELoss
()
...
...
This diff is collapsed.
Click to expand it.
train.py
+
10
−
7
View file @
c1356bff
from
tqdm
import
tqdm
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
torch
def
train
(
model
,
loader
,
f_loss
,
optimizer
,
device
):
"""
...
...
@@ -35,17 +36,19 @@ def train(model, loader, f_loss, optimizer, device):
optimizer
.
zero_grad
()
loss
.
backward
()
#torch.nn.utils.clip_grad_norm(model.parameters(), 50)
#
Y = list(model.parameters())[0].grad.cpu().tolist()
Y
=
list
(
model
.
parameters
())[
0
].
grad
.
cpu
().
tolist
()
#
gradients.append(np.mean(Y))
#
tar.append(np.mean(outputs.cpu().tolist()))
#
out.append(np.mean(targets.cpu().tolist()))
gradients
.
append
(
np
.
mean
(
Y
))
tar
.
append
(
np
.
mean
(
outputs
.
cpu
().
tolist
()))
out
.
append
(
np
.
mean
(
targets
.
cpu
().
tolist
()))
optimizer
.
step
()
#
visualize_gradients(gradients)
#
visualize_gradients(tar)
#
visualize_gradients(out)
visualize_gradients
(
gradients
)
visualize_gradients
(
tar
)
visualize_gradients
(
out
)
def
visualize_gradients
(
gradients
):
print
(
gradients
)
...
...
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