Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet Bachelor
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
projet_2024
Projet Bachelor
Commits
69e2b754
Commit
69e2b754
authored
9 months ago
by
lucien.noel
Browse files
Options
Downloads
Patches
Plain Diff
debut des tests pour trouver les meilleurs paramètres
parent
1ee83c34
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.py
+7
-2
7 additions, 2 deletions
main.py
musicgenerator.py
+2
-2
2 additions, 2 deletions
musicgenerator.py
test.py
+18
-0
18 additions, 0 deletions
test.py
with
27 additions
and
4 deletions
main.py
+
7
−
2
View file @
69e2b754
...
...
@@ -16,8 +16,13 @@ if __name__ == '__main__':
learning_rate
=
20
batch_size
=
16
split_train_test_valid
=
(
0.8
,
0.1
,
0.1
)
model_path
=
os
.
path
.
join
(
data_path
,
'
model.pt
'
)
model_path
=
None
#
os.path.join(data_path, 'model.pt')
sequence_length
=
32
dim_model
=
128
num_head
=
8
num_layers
=
2
num_hid
=
200
dropout
=
0.2
epochs
=
100
nb_log_epoch
=
5
nb_words
=
200
...
...
@@ -42,7 +47,7 @@ if __name__ == '__main__':
with
open
(
model_path
,
'
rb
'
)
as
f
:
model
=
torch
.
load
(
f
,
map_location
=
device
)
else
:
model
=
mg
.
MusicGenerator
(
vocab_size
=
ntokens
,
dim_model
=
512
,
num_head
=
8
).
to
(
device
)
model
=
mg
.
MusicGenerator
(
vocab_size
=
ntokens
,
dim_model
=
dim_model
,
num_head
=
num_head
,
nhid
=
num_hid
,
nlayers
=
num_layers
,
dropout
=
dropout
).
to
(
device
)
criterion
=
nn
.
NLLLoss
()
###############################################################################
...
...
This diff is collapsed.
Click to expand it.
musicgenerator.py
+
2
−
2
View file @
69e2b754
...
...
@@ -28,8 +28,8 @@ class PositionalEncoding(nn.Module):
class
MusicGenerator
(
nn
.
Transformer
):
def
__init__
(
self
,
vocab_size
:
int
,
dim_model
:
int
,
num_head
:
int
,
dropout
=
0.5
):
super
(
MusicGenerator
,
self
).
__init__
(
d_model
=
dim_model
,
nhead
=
num_head
)
def
__init__
(
self
,
vocab_size
:
int
,
dim_model
:
int
,
num_head
:
int
,
nhid
:
int
,
nlayers
:
int
,
dropout
:
float
):
super
(
MusicGenerator
,
self
).
__init__
(
d_model
=
dim_model
,
nhead
=
num_head
,
dim_feedforward
=
nhid
,
num_encoder_layers
=
nlayers
)
self
.
model_type
=
'
Transformer
'
self
.
src_mask
=
None
self
.
pos_encoder
=
PositionalEncoding
(
dim_model
,
dropout
)
...
...
This diff is collapsed.
Click to expand it.
test.py
0 → 100644
+
18
−
0
View file @
69e2b754
import
argparse
import
random
if
__name__
==
'
__main__
'
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
--lr
'
,
type
=
float
,
default
=
20
,
help
=
'
initial learning rate
'
)
parser
.
add_argument
(
'
--epochs
'
,
type
=
int
,
default
=
100
,
help
=
'
upper epoch limit
'
)
parser
.
add_argument
(
'
--batch_size
'
,
type
=
int
,
default
=
16
,
help
=
'
batch size
'
)
parser
.
add_argument
(
'
--sequence_length
'
,
type
=
int
,
default
=
32
,
help
=
'
sequence length
'
)
parser
.
add_argument
(
'
--dimension_model
'
,
type
=
int
,
default
=
128
,
help
=
'
size of word embeddings
'
)
parser
.
add_argument
(
'
--nhead
'
,
type
=
int
,
default
=
4
,
help
=
'
the number of heads in the encoder/decoder of the transformer model
'
)
parser
.
add_argument
(
'
--dropout
'
,
type
=
float
,
default
=
0.2
,
help
=
'
dropout applied to layers (0 = no dropout)
'
)
parser
.
add_argument
(
'
--nhid
'
,
type
=
int
,
default
=
200
,
help
=
'
number of hidden units per layer
'
)
parser
.
add_argument
(
'
--nlayers
'
,
type
=
int
,
default
=
2
,
help
=
'
number of layers
'
)
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