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
ccf9a521
Commit
ccf9a521
authored
Jan 03, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pep8 style in /scripts
parent
9b69e860
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
74 deletions
+74
-74
scripts/checkpoint-manipulate.py
scripts/checkpoint-manipulate.py
+2
-3
scripts/dump-dataflow.py
scripts/dump-dataflow.py
+2
-6
scripts/dump-model-params.py
scripts/dump-model-params.py
+4
-3
scripts/plot-point.py
scripts/plot-point.py
+65
-59
scripts/serve-data.py
scripts/serve-data.py
+1
-3
No files found.
scripts/checkpoint-manipulate.py
View file @
ccf9a521
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
import
numpy
as
np
import
numpy
as
np
from
tensorpack.tfutils.varmanip
import
dump_chkpt_vars
from
tensorpack.tfutils.varmanip
import
dump_chkpt_vars
from
tensorpack.utils
import
logger
from
tensorpack.utils
import
logger
import
tensorflow
as
tf
import
sys
import
argparse
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
@@ -26,4 +24,5 @@ logger.info(str(params.keys()))
...
@@ -26,4 +24,5 @@ logger.info(str(params.keys()))
if
args
.
dump
:
if
args
.
dump
:
np
.
save
(
args
.
dump
,
params
)
np
.
save
(
args
.
dump
,
params
)
if
args
.
shell
:
if
args
.
shell
:
import
IPython
as
IP
;
IP
.
embed
(
config
=
IP
.
terminal
.
ipapp
.
load_default_config
())
import
IPython
as
IP
IP
.
embed
(
config
=
IP
.
terminal
.
ipapp
.
load_default_config
())
scripts/dump-dataflow.py
View file @
ccf9a521
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# -*- coding: UTF-8 -*-
# File: dump
_train_config
.py
# File: dump
-dataflow
.py
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
import
argparse
import
argparse
import
cv2
import
cv2
import
tensorflow
as
tf
import
imp
import
imp
import
tqdm
import
tqdm
import
os
import
os
from
tensorpack.utils
import
logger
from
tensorpack.utils
import
logger
from
tensorpack.utils.fs
import
mkdir_p
from
tensorpack.utils.fs
import
mkdir_p
from
tensorpack.dataflow
import
*
from
tensorpack.dataflow
import
RepeatedData
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
@@ -54,6 +53,3 @@ with tqdm.tqdm(total=NR_DP_TEST, leave=True, unit='data points') as pbar:
...
@@ -54,6 +53,3 @@ with tqdm.tqdm(total=NR_DP_TEST, leave=True, unit='data points') as pbar:
if
idx
>
NR_DP_TEST
:
if
idx
>
NR_DP_TEST
:
break
break
pbar
.
update
()
pbar
.
update
()
scripts/dump-model-params.py
View file @
ccf9a521
...
@@ -8,8 +8,9 @@ import argparse
...
@@ -8,8 +8,9 @@ import argparse
import
tensorflow
as
tf
import
tensorflow
as
tf
import
imp
import
imp
from
tensorpack
import
*
from
tensorpack
import
TowerContext
,
logger
,
ModelFromMetaGraph
from
tensorpack.tfutils
import
sessinit
,
varmanip
from
tensorpack.tfutils
import
sessinit
,
varmanip
from
tensorpack.utils.naming
import
EXTRA_SAVE_VARS_KEY
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--config'
,
help
=
'config file'
)
parser
.
add_argument
(
'--config'
,
help
=
'config file'
)
...
@@ -51,6 +52,6 @@ with tf.Graph().as_default() as G:
...
@@ -51,6 +52,6 @@ with tf.Graph().as_default() as G:
logger
.
info
(
"Variables to dump:"
)
logger
.
info
(
"Variables to dump:"
)
logger
.
info
(
", "
.
join
(
var_dict
.
keys
()))
logger
.
info
(
", "
.
join
(
var_dict
.
keys
()))
saver
=
tf
.
train
.
Saver
(
saver
=
tf
.
train
.
Saver
(
var_list
=
var_dict
,
var_list
=
var_dict
,
write_version
=
tf
.
train
.
SaverDef
.
V2
)
write_version
=
tf
.
train
.
SaverDef
.
V2
)
saver
.
save
(
sess
,
args
.
output
,
write_meta_graph
=
False
)
saver
.
save
(
sess
,
args
.
output
,
write_meta_graph
=
False
)
scripts/plot-point.py
View file @
ccf9a521
...
@@ -14,96 +14,99 @@ $ cat examples/train_log/mnist-convnet/stat.json \
...
@@ -14,96 +14,99 @@ $ cat examples/train_log/mnist-convnet/stat.json \
For more usage, see `plot-point.py -h` or the code.
For more usage, see `plot-point.py -h` or the code.
"""
"""
from
math
import
*
import
numpy
as
np
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
matplotlib.font_manager
as
fontm
import
matplotlib.font_manager
as
fontm
import
argparse
,
sys
import
argparse
import
sys
from
collections
import
defaultdict
from
collections
import
defaultdict
from
itertools
import
chain
from
itertools
import
chain
import
six
import
six
from
matplotlib
import
rc
#
from matplotlib import rc
#rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
#
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
#rc('font',**{'family':'sans-serif','sans-serif':['Microsoft Yahei']})
#
rc('font',**{'family':'sans-serif','sans-serif':['Microsoft Yahei']})
#rc('text', usetex=True)
#
rc('text', usetex=True)
STDIN_FNAME
=
'-'
STDIN_FNAME
=
'-'
def
get_args
():
def
get_args
():
description
=
"plot points into graph."
description
=
"plot points into graph."
parser
=
argparse
.
ArgumentParser
(
description
=
description
)
parser
=
argparse
.
ArgumentParser
(
description
=
description
)
parser
.
add_argument
(
'-i'
,
'--input'
,
parser
.
add_argument
(
'-i'
,
'--input'
,
help
=
'input data file, use "-" for stdin. Default stdin. Input
\
help
=
'input data file, use "-" for stdin. Default stdin. Input
\
format is many rows of DELIMIETER-separated data'
,
format is many rows of DELIMIETER-separated data'
,
default
=
'-'
)
default
=
'-'
)
parser
.
add_argument
(
'-o'
,
'--output'
,
parser
.
add_argument
(
'-o'
,
'--output'
,
help
=
'output image'
,
default
=
''
)
help
=
'output image'
,
default
=
''
)
parser
.
add_argument
(
'--show'
,
parser
.
add_argument
(
'--show'
,
help
=
'show the figure after rendered'
,
help
=
'show the figure after rendered'
,
action
=
'store_true'
)
action
=
'store_true'
)
parser
.
add_argument
(
'-c'
,
'--column'
,
parser
.
add_argument
(
'-c'
,
'--column'
,
help
=
"describe each column in data, for example 'x,y,y'.
\
help
=
"describe each column in data, for example 'x,y,y'.
\
Default to 'y' for one column and 'x,y' for two columns.
\
Default to 'y' for one column and 'x,y' for two columns.
\
Plot attributes can be appended after 'y', like 'ythick;cr'.
\
Plot attributes can be appended after 'y', like 'ythick;cr'.
\
By default, assume all columns are y.
\
By default, assume all columns are y.
\
"
)
"
)
parser
.
add_argument
(
'-t'
,
'--title'
,
parser
.
add_argument
(
'-t'
,
'--title'
,
help
=
'title of the graph'
,
help
=
'title of the graph'
,
default
=
''
)
default
=
''
)
parser
.
add_argument
(
'--xlabel'
,
parser
.
add_argument
(
'--xlabel'
,
help
=
'x label'
,
type
=
six
.
text_type
)
help
=
'x label'
,
type
=
six
.
text_type
)
parser
.
add_argument
(
'--ylabel'
,
parser
.
add_argument
(
'--ylabel'
,
help
=
'y label'
,
type
=
six
.
text_type
)
help
=
'y label'
,
type
=
six
.
text_type
)
parser
.
add_argument
(
'--xlim'
,
parser
.
add_argument
(
'--xlim'
,
help
=
'x lim'
,
type
=
float
,
nargs
=
2
)
help
=
'x lim'
,
type
=
float
,
nargs
=
2
)
parser
.
add_argument
(
'--ylim'
,
parser
.
add_argument
(
'--ylim'
,
help
=
'y lim'
,
type
=
float
,
nargs
=
2
)
help
=
'y lim'
,
type
=
float
,
nargs
=
2
)
parser
.
add_argument
(
'-s'
,
'--scale'
,
parser
.
add_argument
(
'-s'
,
'--scale'
,
help
=
'scale of each y, separated by comma'
)
help
=
'scale of each y, separated by comma'
)
parser
.
add_argument
(
'--annotate-maximum'
,
parser
.
add_argument
(
'--annotate-maximum'
,
help
=
'annonate maximum value in graph'
,
help
=
'annonate maximum value in graph'
,
action
=
'store_true'
)
action
=
'store_true'
)
parser
.
add_argument
(
'--annotate-minimum'
,
parser
.
add_argument
(
'--annotate-minimum'
,
help
=
'annonate minimum value in graph'
,
help
=
'annonate minimum value in graph'
,
action
=
'store_true'
)
action
=
'store_true'
)
parser
.
add_argument
(
'--xkcd'
,
parser
.
add_argument
(
'--xkcd'
,
help
=
'xkcd style'
,
help
=
'xkcd style'
,
action
=
'store_true'
)
action
=
'store_true'
)
parser
.
add_argument
(
'--decay'
,
parser
.
add_argument
(
'--decay'
,
help
=
'exponential decay rate to smooth Y'
,
help
=
'exponential decay rate to smooth Y'
,
type
=
float
,
default
=
0
)
type
=
float
,
default
=
0
)
parser
.
add_argument
(
'-l'
,
'--legend'
,
parser
.
add_argument
(
'-l'
,
'--legend'
,
help
=
'legend for each y'
)
help
=
'legend for each y'
)
parser
.
add_argument
(
'-d'
,
'--delimeter'
,
parser
.
add_argument
(
'-d'
,
'--delimeter'
,
help
=
'column delimeter'
,
default
=
'
\t
'
)
help
=
'column delimeter'
,
default
=
'
\t
'
)
global
args
global
args
args
=
parser
.
parse_args
()
;
args
=
parser
.
parse_args
()
if
not
args
.
show
and
not
args
.
output
:
if
not
args
.
show
and
not
args
.
output
:
args
.
show
=
True
args
.
show
=
True
def
filter_valid_range
(
points
,
rect
):
def
filter_valid_range
(
points
,
rect
):
"""rect = (min_x, max_x, min_y, max_y)"""
"""rect = (min_x, max_x, min_y, max_y)"""
ret
=
[]
ret
=
[]
for
x
,
y
in
points
:
for
x
,
y
in
points
:
if
x
>=
rect
[
0
]
and
x
<=
rect
[
1
]
and
y
>=
rect
[
2
]
and
y
<=
rect
[
3
]:
if
x
>=
rect
[
0
]
and
x
<=
rect
[
1
]
and
y
>=
rect
[
2
]
and
y
<=
rect
[
3
]:
ret
.
append
((
x
,
y
))
ret
.
append
((
x
,
y
))
if
len
(
ret
)
==
0
:
if
len
(
ret
)
==
0
:
ret
.
append
(
points
[
0
])
ret
.
append
(
points
[
0
])
return
ret
return
ret
def
exponential_smooth
(
data
,
alpha
):
def
exponential_smooth
(
data
,
alpha
):
""" smooth data by alpha. returned a smoothed version"""
""" smooth data by alpha. returned a smoothed version"""
ret
=
np
.
copy
(
data
)
ret
=
np
.
copy
(
data
)
now
=
data
[
0
]
now
=
data
[
0
]
for
k
in
range
(
len
(
data
)):
for
k
in
range
(
len
(
data
)):
ret
[
k
]
=
now
*
alpha
+
data
[
k
]
*
(
1
-
alpha
)
ret
[
k
]
=
now
*
alpha
+
data
[
k
]
*
(
1
-
alpha
)
now
=
ret
[
k
]
now
=
ret
[
k
]
return
ret
return
ret
def
annotate_min_max
(
data_x
,
data_y
,
ax
):
def
annotate_min_max
(
data_x
,
data_y
,
ax
):
max_x
,
min_x
=
max
(
data_x
),
min
(
data_x
)
max_x
,
min_x
=
max
(
data_x
),
min
(
data_x
)
max_y
,
min_y
=
max
(
data_y
),
min
(
data_y
)
max_y
,
min_y
=
max
(
data_y
),
min
(
data_y
)
...
@@ -133,9 +136,9 @@ def annotate_min_max(data_x, data_y, ax):
...
@@ -133,9 +136,9 @@ def annotate_min_max(data_x, data_y, ax):
y_max
-
0.025
*
y_range
)],
y_max
-
0.025
*
y_range
)],
rect
)[
0
]
rect
)[
0
]
ax
.
annotate
(
'maximum ({:d},{:.3f})'
.
format
(
int
(
x_max
),
y_max
),
ax
.
annotate
(
'maximum ({:d},{:.3f})'
.
format
(
int
(
x_max
),
y_max
),
xy
=
(
x_max
,
y_max
),
xy
=
(
x_max
,
y_max
),
xytext
=
(
text_x
,
text_y
),
xytext
=
(
text_x
,
text_y
),
arrowprops
=
dict
(
arrowstyle
=
'->'
))
arrowprops
=
dict
(
arrowstyle
=
'->'
))
if
args
.
annotate_minimum
:
if
args
.
annotate_minimum
:
text_x
,
text_y
=
filter_valid_range
([
text_x
,
text_y
=
filter_valid_range
([
(
x_min
+
0.05
*
x_range
,
(
x_min
+
0.05
*
x_range
,
...
@@ -148,13 +151,14 @@ def annotate_min_max(data_x, data_y, ax):
...
@@ -148,13 +151,14 @@ def annotate_min_max(data_x, data_y, ax):
y_min
+
0.025
*
y_range
)],
y_min
+
0.025
*
y_range
)],
rect
)[
0
]
rect
)[
0
]
ax
.
annotate
(
'minimum ({:d},{:.3f})'
.
format
(
int
(
x_min
),
y_min
),
ax
.
annotate
(
'minimum ({:d},{:.3f})'
.
format
(
int
(
x_min
),
y_min
),
xy
=
(
x_min
,
y_min
),
xy
=
(
x_min
,
y_min
),
xytext
=
(
text_x
,
text_y
),
xytext
=
(
text_x
,
text_y
),
arrowprops
=
dict
(
arrowstyle
=
'->'
))
arrowprops
=
dict
(
arrowstyle
=
'->'
))
#ax.annotate('{:.3f}' . format(y_min),
# ax.annotate('{:.3f}' . format(y_min),
#xy = (x_min, y_min),
# xy = (x_min, y_min),
#xytext = (text_x, text_y),
# xytext = (text_x, text_y),
#arrowprops = dict(arrowstyle = '->'))
# arrowprops = dict(arrowstyle = '->'))
def
plot_args_from_column_desc
(
desc
):
def
plot_args_from_column_desc
(
desc
):
if
not
desc
:
if
not
desc
:
...
@@ -170,12 +174,13 @@ def plot_args_from_column_desc(desc):
...
@@ -170,12 +174,13 @@ def plot_args_from_column_desc(desc):
ret
[
'color'
]
=
v
[
1
:]
ret
[
'color'
]
=
v
[
1
:]
return
ret
return
ret
def
do_plot
(
data_xs
,
data_ys
):
def
do_plot
(
data_xs
,
data_ys
):
"""
"""
data_xs: list of 1d array, either of size 1 or size len(data_ys)
data_xs: list of 1d array, either of size 1 or size len(data_ys)
data_ys: list of 1d array
data_ys: list of 1d array
"""
"""
fig
=
plt
.
figure
(
figsize
=
(
16.18
/
1.2
,
10
/
1.2
))
fig
=
plt
.
figure
(
figsize
=
(
16.18
/
1.2
,
10
/
1.2
))
ax
=
fig
.
add_axes
((
0.1
,
0.2
,
0.8
,
0.7
))
ax
=
fig
.
add_axes
((
0.1
,
0.2
,
0.8
,
0.7
))
nr_y
=
len
(
data_ys
)
nr_y
=
len
(
data_ys
)
y_column
=
args
.
y_column
y_column
=
args
.
y_column
...
@@ -185,7 +190,7 @@ def do_plot(data_xs, data_ys):
...
@@ -185,7 +190,7 @@ def do_plot(data_xs, data_ys):
legends
=
args
.
legend
.
split
(
','
)
legends
=
args
.
legend
.
split
(
','
)
assert
len
(
legends
)
==
nr_y
assert
len
(
legends
)
==
nr_y
else
:
else
:
legends
=
None
#
range(nr_y) #None
legends
=
None
#
range(nr_y) #None
if
args
.
scale
:
if
args
.
scale
:
scale
=
map
(
float
,
args
.
scale
.
split
(
','
))
scale
=
map
(
float
,
args
.
scale
.
split
(
','
))
assert
len
(
scale
)
==
nr_y
assert
len
(
scale
)
==
nr_y
...
@@ -201,19 +206,19 @@ def do_plot(data_xs, data_ys):
...
@@ -201,19 +206,19 @@ def do_plot(data_xs, data_ys):
leg
=
"{}*{}"
.
format
(
now_scale
if
int
(
now_scale
)
!=
now_scale
else
int
(
now_scale
),
leg
)
leg
=
"{}*{}"
.
format
(
now_scale
if
int
(
now_scale
)
!=
now_scale
else
int
(
now_scale
),
leg
)
data_x
=
data_xs
[
0
]
if
len
(
data_xs
)
==
1
else
data_xs
[
yidx
]
data_x
=
data_xs
[
0
]
if
len
(
data_xs
)
==
1
else
data_xs
[
yidx
]
assert
len
(
data_x
)
>=
len
(
data_y
),
\
assert
len
(
data_x
)
>=
len
(
data_y
),
\
"x column is shorter than y column! {} < {}"
.
format
(
"x column is shorter than y column! {} < {}"
.
format
(
len
(
data_x
),
len
(
data_y
))
len
(
data_x
),
len
(
data_y
))
truncate_data_x
=
data_x
[:
len
(
data_y
)]
truncate_data_x
=
data_x
[:
len
(
data_y
)]
p
=
plt
.
plot
(
truncate_data_x
,
data_y
,
label
=
leg
,
**
plotargs
)
p
=
plt
.
plot
(
truncate_data_x
,
data_y
,
label
=
leg
,
**
plotargs
)
c
=
p
[
0
]
.
get_color
()
c
=
p
[
0
]
.
get_color
()
plt
.
fill_between
(
truncate_data_x
,
data_y
,
alpha
=
0.1
,
facecolor
=
c
)
plt
.
fill_between
(
truncate_data_x
,
data_y
,
alpha
=
0.1
,
facecolor
=
c
)
#ax.set_aspect('equal', 'datalim')
#
ax.set_aspect('equal', 'datalim')
#ax.spines['right'].set_color('none')
#
ax.spines['right'].set_color('none')
#ax.spines['left'].set_color('none')
#
ax.spines['left'].set_color('none')
#plt.xticks([])
#
plt.xticks([])
#plt.yticks([])
#
plt.yticks([])
if
args
.
annotate_maximum
or
args
.
annotate_minimum
:
if
args
.
annotate_maximum
or
args
.
annotate_minimum
:
annotate_min_max
(
truncate_data_x
,
data_y
,
ax
)
annotate_min_max
(
truncate_data_x
,
data_y
,
ax
)
...
@@ -237,7 +242,7 @@ def do_plot(data_xs, data_ys):
...
@@ -237,7 +242,7 @@ def do_plot(data_xs, data_ys):
[
ax
.
get_xticklabels
(),
ax
.
get_yticklabels
()]):
[
ax
.
get_xticklabels
(),
ax
.
get_yticklabels
()]):
label
.
set_fontproperties
(
fontm
.
FontProperties
(
size
=
15
))
label
.
set_fontproperties
(
fontm
.
FontProperties
(
size
=
15
))
ax
.
grid
(
color
=
'gray'
,
linestyle
=
'dashed'
)
ax
.
grid
(
color
=
'gray'
,
linestyle
=
'dashed'
)
plt
.
title
(
args
.
title
,
fontdict
=
{
'fontsize'
:
'20'
})
plt
.
title
(
args
.
title
,
fontdict
=
{
'fontsize'
:
'20'
})
...
@@ -246,6 +251,7 @@ def do_plot(data_xs, data_ys):
...
@@ -246,6 +251,7 @@ def do_plot(data_xs, data_ys):
if
args
.
show
:
if
args
.
show
:
plt
.
show
()
plt
.
show
()
def
main
():
def
main
():
get_args
()
get_args
()
# parse input args
# parse input args
...
@@ -263,7 +269,8 @@ def main():
...
@@ -263,7 +269,8 @@ def main():
column
=
[
'y'
]
*
nr_column
column
=
[
'y'
]
*
nr_column
else
:
else
:
column
=
args
.
column
.
strip
()
.
split
(
','
)
column
=
args
.
column
.
strip
()
.
split
(
','
)
for
k
in
column
:
assert
k
[
0
]
in
[
'x'
,
'y'
]
for
k
in
column
:
assert
k
[
0
]
in
[
'x'
,
'y'
]
assert
nr_column
==
len
(
column
),
"Column and data doesn't have same length. {}!={}"
.
format
(
nr_column
,
len
(
column
))
assert
nr_column
==
len
(
column
),
"Column and data doesn't have same length. {}!={}"
.
format
(
nr_column
,
len
(
column
))
args
.
y_column
=
[
v
for
v
in
column
if
v
[
0
]
==
'y'
]
args
.
y_column
=
[
v
for
v
in
column
if
v
[
0
]
==
'y'
]
args
.
y_column_idx
=
[
idx
for
idx
,
v
in
enumerate
(
column
)
if
v
[
0
]
==
'y'
]
args
.
y_column_idx
=
[
idx
for
idx
,
v
in
enumerate
(
column
)
if
v
[
0
]
==
'y'
]
...
@@ -275,11 +282,9 @@ def main():
...
@@ -275,11 +282,9 @@ def main():
assert
nr_x_column
==
nr_y_column
,
\
assert
nr_x_column
==
nr_y_column
,
\
"If multiple x columns are used, nr_x_column must equals to nr_y_column"
"If multiple x columns are used, nr_x_column must equals to nr_y_column"
x_column_set
=
set
(
args
.
x_column
)
# read and parse data
# read and parse data
data
=
[[]
for
_
in
range
(
nr_column
)]
data
=
[[]
for
_
in
range
(
nr_column
)]
ended
=
defaultdict
(
bool
)
ended
=
defaultdict
(
bool
)
data_format
=
-
1
for
lineno
,
line
in
enumerate
(
all_inputs
):
for
lineno
,
line
in
enumerate
(
all_inputs
):
line
=
line
.
rstrip
(
'
\n
'
)
.
split
(
args
.
delimeter
)
line
=
line
.
rstrip
(
'
\n
'
)
.
split
(
args
.
delimeter
)
assert
len
(
line
)
<=
nr_column
,
\
assert
len
(
line
)
<=
nr_column
,
\
...
@@ -302,14 +307,14 @@ Line: {}""".format(repr(args.delimeter), line)
...
@@ -302,14 +307,14 @@ Line: {}""".format(repr(args.delimeter), line)
if
nr_x_column
:
if
nr_x_column
:
data_xs
=
[
data
[
k
]
for
k
in
args
.
x_column_idx
]
data_xs
=
[
data
[
k
]
for
k
in
args
.
x_column_idx
]
else
:
else
:
data_xs
=
[
list
(
range
(
1
,
max_ysize
+
1
))]
data_xs
=
[
list
(
range
(
1
,
max_ysize
+
1
))]
for
idx
,
data_y
in
enumerate
(
data_ys
):
for
idx
,
data_y
in
enumerate
(
data_ys
):
data_ys
[
idx
]
=
np
.
asarray
(
data_y
)
data_ys
[
idx
]
=
np
.
asarray
(
data_y
)
if
args
.
decay
!=
0
:
if
args
.
decay
!=
0
:
data_ys
[
idx
]
=
exponential_smooth
(
data_y
,
args
.
decay
)
data_ys
[
idx
]
=
exponential_smooth
(
data_y
,
args
.
decay
)
#if idx == 0: # TODO allow different decay for each y
#
if idx == 0: # TODO allow different decay for each y
#data_ys[idx] = exponential_smooth(data_y, 0.5)
#
data_ys[idx] = exponential_smooth(data_y, 0.5)
for
idx
,
data_x
in
enumerate
(
data_xs
):
for
idx
,
data_x
in
enumerate
(
data_xs
):
data_xs
[
idx
]
=
np
.
asarray
(
data_x
)
data_xs
[
idx
]
=
np
.
asarray
(
data_x
)
...
@@ -319,5 +324,6 @@ Line: {}""".format(repr(args.delimeter), line)
...
@@ -319,5 +324,6 @@ Line: {}""".format(repr(args.delimeter), line)
else
:
else
:
do_plot
(
data_xs
,
data_ys
)
do_plot
(
data_xs
,
data_ys
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
scripts/serve-data.py
View file @
ccf9a521
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# File: serve
_
data.py
# File: serve
-
data.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import
argparse
import
argparse
import
imp
import
imp
#import cv2
#import os
from
tensorpack.dataflow
import
serve_data
from
tensorpack.dataflow
import
serve_data
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
...
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