Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
deepFriedConvnet
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
Container Registry
Model registry
Operate
Environments
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
Luc Giffon
deepFriedConvnet
Commits
080f5413
Commit
080f5413
authored
7 years ago
by
Luc Giffon
Browse files
Options
Downloads
Patches
Plain Diff
update nys vs nystrom experiment
parent
1ce25f01
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main/experiments/build_command_line_array_nys_vs_deepstrom.py
+21
-0
21 additions, 0 deletions
.../experiments/build_command_line_array_nys_vs_deepstrom.py
main/experiments/nystrom_vs_deepstrom.py
+24
-11
24 additions, 11 deletions
main/experiments/nystrom_vs_deepstrom.py
with
45 additions
and
11 deletions
main/experiments/build_command_line_array_nys_vs_deepstrom.py
0 → 100644
+
21
−
0
View file @
080f5413
import
numpy
as
np
if
__name__
==
'
__main__
'
:
batch_size
=
np
.
logspace
(
3
,
9
,
dtype
=
int
,
base
=
2
,
num
=
5
)
num_epochs
=
np
.
linspace
(
200
,
200
,
num
=
1
)
gamma
=
0.003
subsample_size
=
np
.
logspace
(
3
,
9
,
dtype
=
int
,
base
=
2
,
num
=
5
)
networks_types
=
[
"
nystroem
"
,
"
deepstrom
"
]
for
network
in
networks_types
:
s_network
=
"
--
"
+
network
+
"
"
s_gamma
=
s_network
+
"
-G
"
+
str
(
gamma
)
+
"
"
for
nys_size
in
subsample_size
:
s_nys
=
s_gamma
+
"
-m
"
+
str
(
nys_size
)
+
"
"
if
network
==
"
deepstrom
"
:
for
num_epoch
in
num_epochs
:
s_epoch
=
s_nys
+
"
-e
"
+
"
"
+
str
(
int
(
num_epoch
))
+
"
"
for
b_size
in
batch_size
:
s_batch
=
s_epoch
+
"
-s
"
+
str
(
b_size
)
+
"
"
print
(
s_batch
)
else
:
print
(
s_nys
)
This diff is collapsed.
Click to expand it.
main/experiments/nystrom_vs_deepstrom.py
+
24
−
11
View file @
080f5413
...
@@ -9,10 +9,10 @@ Options:
...
@@ -9,10 +9,10 @@ Options:
-h --help Show this screen.
-h --help Show this screen.
--nystroem Run the nystroem version.
--nystroem Run the nystroem version.
--deepstrom Run the deepstrom version.
--deepstrom Run the deepstrom version.
-e numepoch --num-epoch=numepoch The number of epoch. [default: 1]
-s batchsize --batch-size=batchsize The number of example in each batch [default: 50]
-G gammavalue --gamma-nystrom=gammavalue The gamma value used in nystrom.
-G gammavalue --gamma-nystrom=gammavalue The gamma value used in nystrom.
-m subsamplesize --subsample-size-nystrom=subsamplesize The subsample size for nystrom.
-m subsamplesize --subsample-size-nystrom=subsamplesize The subsample size for nystrom.
-e numepoch --num-epoch=numepoch The number of epoch. [default: 1]
-s batchsize --batch-size=batchsize The number of example in each batch [default: 50]
"""
"""
import
tensorflow
as
tf
import
tensorflow
as
tf
...
@@ -21,7 +21,7 @@ import skluc.mldatasets as dataset
...
@@ -21,7 +21,7 @@ import skluc.mldatasets as dataset
from
sklearn.kernel_approximation
import
Nystroem
from
sklearn.kernel_approximation
import
Nystroem
from
sklearn.svm
import
SVC
from
sklearn.svm
import
SVC
from
nystrom.nystrom_approx
import
nystrom_layer
from
skluc.
nystrom.nystrom_approx
import
nystrom_layer
from
skluc.neural_networks
import
batch_generator
,
classification_mnist
from
skluc.neural_networks
import
batch_generator
,
classification_mnist
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
ERROR
)
tf
.
logging
.
set_verbosity
(
tf
.
logging
.
ERROR
)
...
@@ -29,10 +29,18 @@ tf.logging.set_verbosity(tf.logging.ERROR)
...
@@ -29,10 +29,18 @@ tf.logging.set_verbosity(tf.logging.ERROR)
import
docopt
import
docopt
def
deepstrom_classif
(
X_train
,
Y_train
,
X_nystrom
,
batch_size
,
def
deepstrom_classif
(
X_train
,
num_epoch
,
dataset_cycling
,
Y_train
,
gamma
,
data_shape
,
output_dim
,
output_nystrom_layer
,
X_nystrom
,
X_test
=
None
,
Y_test
=
None
):
batch_size
,
num_epoch
,
dataset_cycling
,
gamma
,
data_shape
,
output_dim
,
output_nystrom_layer
,
X_test
=
None
,
Y_test
=
None
):
with
tf
.
Graph
().
as_default
():
with
tf
.
Graph
().
as_default
():
...
@@ -77,7 +85,8 @@ def deepstrom_classif(X_train, Y_train, X_nystrom, batch_size,
...
@@ -77,7 +85,8 @@ def deepstrom_classif(X_train, Y_train, X_nystrom, batch_size,
# testing or predicting may not be wanted
# testing or predicting may not be wanted
accuracy
=
sess
.
run
([
accuracy_op
],
feed_dict
=
{
accuracy
=
sess
.
run
([
accuracy_op
],
feed_dict
=
{
x
:
X_test
,
y_
:
Y_test
,
keep_prob
:
1.0
})
x
:
X_test
,
y_
:
Y_test
,
keep_prob
:
1.0
})
print
(
accuracy
)
lst_output
=
[
str
(
accuracy
[
0
]),
str
(
x_nystrom
.
shape
[
0
]),
str
(
gamma
),
str
(
batch_size
),
str
(
num_epoch
)]
print
(
"
,
"
.
join
(
lst_output
))
def
nystroem_classif
(
X_train
,
Y_train
,
X_test
,
Y_test
,
subsample
,
gamma
):
def
nystroem_classif
(
X_train
,
Y_train
,
X_test
,
Y_test
,
subsample
,
gamma
):
...
@@ -87,22 +96,26 @@ def nystroem_classif(X_train, Y_train, X_test, Y_test, subsample, gamma):
...
@@ -87,22 +96,26 @@ def nystroem_classif(X_train, Y_train, X_test, Y_test, subsample, gamma):
X_test_transformed
=
nys
.
transform
(
X_test
)
X_test_transformed
=
nys
.
transform
(
X_test
)
clf
=
SVC
(
kernel
=
"
linear
"
)
clf
=
SVC
(
kernel
=
"
linear
"
)
clf
.
fit
(
X_train_transformed
,
Y_train
)
clf
.
fit
(
X_train_transformed
,
Y_train
)
print
(
clf
.
score
(
X_test_transformed
,
Y_test
))
score
=
clf
.
score
(
X_test_transformed
,
Y_test
)
lst_output
=
[
str
(
score
),
str
(
len
(
subsample
)),
str
(
gamma
)]
print
(
"
,
"
.
join
(
lst_output
))
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
arguments
=
docopt
.
docopt
(
__doc__
)
arguments
=
docopt
.
docopt
(
__doc__
)
print
(
arguments
)
#
print(arguments)
SUBSAMPLE_SIZE
=
int
(
arguments
[
"
--subsample-size-nystrom
"
])
SUBSAMPLE_SIZE
=
int
(
arguments
[
"
--subsample-size-nystrom
"
])
gamma
=
float
(
arguments
[
"
--gamma-nystrom
"
])
gamma
=
float
(
arguments
[
"
--gamma-nystrom
"
])
nystroem
=
arguments
[
"
--nystroem
"
]
nystroem
=
arguments
[
"
--nystroem
"
]
deepstrom
=
arguments
[
"
--deepstrom
"
]
deepstrom
=
arguments
[
"
--deepstrom
"
]
num_epoch
=
int
(
arguments
[
"
--num-epoch
"
])
num_epoch
=
int
(
float
(
arguments
[
"
--num-epoch
"
])
)
batch_size
=
int
(
arguments
[
"
--batch-size
"
])
batch_size
=
int
(
arguments
[
"
--batch-size
"
])
mnist
=
dataset
.
MnistDataset
()
mnist
=
dataset
.
MnistDataset
()
mnist
.
load
()
mnist
.
load
()
mnist
.
normalize
()
mnist
.
normalize
()
np
.
random
.
seed
(
0
)
indexes_nystrom
=
np
.
random
.
permutation
(
60000
)[:
SUBSAMPLE_SIZE
]
indexes_nystrom
=
np
.
random
.
permutation
(
60000
)[:
SUBSAMPLE_SIZE
]
if
nystroem
:
if
nystroem
:
...
...
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