Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
66726a8f
You need to sign in or sign up before continuing.
Commit
66726a8f
authored
Jul 29, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move use_global_argument into ns
parent
901727fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
examples/GAN/DCGAN.py
examples/GAN/DCGAN.py
+1
-2
tensorpack/utils/globvars.py
tensorpack/utils/globvars.py
+13
-11
No files found.
examples/GAN/DCGAN.py
View file @
66726a8f
...
@@ -13,7 +13,6 @@ from tensorpack.utils.viz import *
...
@@ -13,7 +13,6 @@ from tensorpack.utils.viz import *
from
tensorpack.tfutils.summary
import
add_moving_summary
from
tensorpack.tfutils.summary
import
add_moving_summary
from
tensorpack.tfutils.scope_utils
import
auto_reuse_variable_scope
from
tensorpack.tfutils.scope_utils
import
auto_reuse_variable_scope
from
tensorpack.utils.globvars
import
globalns
as
opt
from
tensorpack.utils.globvars
import
globalns
as
opt
from
tensorpack.utils.globvars
import
use_global_argument
import
tensorflow
as
tf
import
tensorflow
as
tf
from
GAN
import
GANTrainer
,
RandomZData
,
GANModelDesc
from
GAN
import
GANTrainer
,
RandomZData
,
GANModelDesc
...
@@ -153,7 +152,7 @@ def get_args():
...
@@ -153,7 +152,7 @@ def get_args():
parser
.
add_argument
(
'--load-size'
,
help
=
'size to load the original images'
,
type
=
int
)
parser
.
add_argument
(
'--load-size'
,
help
=
'size to load the original images'
,
type
=
int
)
parser
.
add_argument
(
'--crop-size'
,
help
=
'crop the original images'
,
type
=
int
)
parser
.
add_argument
(
'--crop-size'
,
help
=
'crop the original images'
,
type
=
int
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
use_global
_argument
(
args
)
opt
.
use
_argument
(
args
)
if
args
.
gpu
:
if
args
.
gpu
:
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
return
args
return
args
...
...
tensorpack/utils/globvars.py
View file @
66726a8f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
import
six
import
six
import
argparse
import
argparse
__all__
=
[
'globalns'
,
'use_global_argument'
]
__all__
=
[
'globalns'
]
if
six
.
PY2
:
if
six
.
PY2
:
class
NS
:
class
NS
:
...
@@ -15,16 +15,18 @@ else:
...
@@ -15,16 +15,18 @@ else:
import
types
import
types
NS
=
types
.
SimpleNamespace
NS
=
types
.
SimpleNamespace
globalns
=
NS
()
class
MyNS
(
NS
):
def
use_global_argument
(
args
):
def
use_argument
(
self
,
args
):
"""
"""
Add the content of :class:`argparse.Namespace` to global
ns.
Add the content of :class:`argparse.Namespace` to this
ns.
Args:
Args:
args (argparse.Namespace): arguments
args (argparse.Namespace): arguments
"""
"""
assert
isinstance
(
args
,
argparse
.
Namespace
),
type
(
args
)
assert
isinstance
(
args
,
argparse
.
Namespace
),
type
(
args
)
for
k
,
v
in
six
.
iteritems
(
vars
(
args
)):
for
k
,
v
in
six
.
iteritems
(
vars
(
args
)):
setattr
(
globalns
,
k
,
v
)
setattr
(
self
,
k
,
v
)
globalns
=
MyNS
()
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