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
ba679ab1
Commit
ba679ab1
authored
Mar 18, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
placeholder->TensorSpec refactor
parent
0aa92de5
Changes
36
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
96 additions
and
98 deletions
+96
-98
docs/tutorial/training-interface.md
docs/tutorial/training-interface.md
+1
-1
examples/A3C-Gym/train-atari.py
examples/A3C-Gym/train-atari.py
+4
-4
examples/CTC-TIMIT/train-timit.py
examples/CTC-TIMIT/train-timit.py
+5
-5
examples/Char-RNN/char-rnn.py
examples/Char-RNN/char-rnn.py
+2
-2
examples/DeepQNetwork/DQNModel.py
examples/DeepQNetwork/DQNModel.py
+4
-6
examples/DoReFa-Net/resnet-dorefa.py
examples/DoReFa-Net/resnet-dorefa.py
+2
-2
examples/DoReFa-Net/svhn-digit-dorefa.py
examples/DoReFa-Net/svhn-digit-dorefa.py
+2
-2
examples/DynamicFilterNetwork/steering-filter.py
examples/DynamicFilterNetwork/steering-filter.py
+4
-4
examples/FasterRCNN/train.py
examples/FasterRCNN/train.py
+14
-14
examples/GAN/BEGAN.py
examples/GAN/BEGAN.py
+1
-1
examples/GAN/ConditionalGAN-mnist.py
examples/GAN/ConditionalGAN-mnist.py
+2
-2
examples/GAN/CycleGAN.py
examples/GAN/CycleGAN.py
+2
-2
examples/GAN/DCGAN.py
examples/GAN/DCGAN.py
+1
-1
examples/GAN/DiscoGAN-CelebA.py
examples/GAN/DiscoGAN-CelebA.py
+2
-2
examples/GAN/Image2Image.py
examples/GAN/Image2Image.py
+2
-2
examples/GAN/InfoGAN-mnist.py
examples/GAN/InfoGAN-mnist.py
+1
-1
examples/HED/hed.py
examples/HED/hed.py
+2
-2
examples/ImageNetModels/imagenet_utils.py
examples/ImageNetModels/imagenet_utils.py
+2
-2
examples/ImageNetModels/inception-bn.py
examples/ImageNetModels/inception-bn.py
+2
-2
examples/OpticalFlow/flownet_models.py
examples/OpticalFlow/flownet_models.py
+3
-3
examples/PennTreebank/PTB-LSTM.py
examples/PennTreebank/PTB-LSTM.py
+2
-2
examples/ResNet/cifar10-preact18-mixup.py
examples/ResNet/cifar10-preact18-mixup.py
+2
-2
examples/ResNet/cifar10-resnet.py
examples/ResNet/cifar10-resnet.py
+2
-2
examples/ResNet/load-resnet.py
examples/ResNet/load-resnet.py
+2
-2
examples/Saliency/saliency-maps.py
examples/Saliency/saliency-maps.py
+1
-1
examples/SimilarityLearning/mnist-embeddings.py
examples/SimilarityLearning/mnist-embeddings.py
+8
-8
examples/SpatialTransformer/mnist-addition.py
examples/SpatialTransformer/mnist-addition.py
+2
-2
examples/SuperResolution/enet-pat.py
examples/SuperResolution/enet-pat.py
+2
-2
examples/basics/cifar-convnet.py
examples/basics/cifar-convnet.py
+2
-2
examples/basics/export-model.py
examples/basics/export-model.py
+3
-3
examples/basics/mnist-tflayers.py
examples/basics/mnist-tflayers.py
+2
-2
examples/basics/mnist-tfslim.py
examples/basics/mnist-tfslim.py
+2
-2
examples/basics/mnist-visualizations.py
examples/basics/mnist-visualizations.py
+2
-2
examples/basics/svhn-digit-convnet.py
examples/basics/svhn-digit-convnet.py
+2
-2
examples/boilerplate.py
examples/boilerplate.py
+2
-2
examples/keras/mnist-keras.py
examples/keras/mnist-keras.py
+2
-2
No files found.
docs/tutorial/training-interface.md
View file @
ba679ab1
...
@@ -17,7 +17,7 @@ expects 4 arguments to setup the graph: `InputDesc`, `InputSource`, get_cost fun
...
@@ -17,7 +17,7 @@ expects 4 arguments to setup the graph: `InputDesc`, `InputSource`, get_cost fun
```
python
```
python
class
MyModel
(
ModelDesc
):
class
MyModel
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
dtype
,
shape
,
name
),
tf
.
placeholder
(
dtype
,
sha
pe
,
name
),
...
]
return
[
tf
.
TensorSpec
(
shape
,
dtype
,
name
),
tf
.
TensorSpec
(
shape
,
dty
pe
,
name
),
...
]
def
build_graph
(
self
,
tensorA
,
tensorB
,
...
):
# inputs
def
build_graph
(
self
,
tensorA
,
tensorB
,
...
):
# inputs
# build the graph
# build the graph
...
...
examples/A3C-Gym/train-atari.py
View file @
ba679ab1
...
@@ -69,10 +69,10 @@ class MySimulatorWorker(SimulatorProcess):
...
@@ -69,10 +69,10 @@ class MySimulatorWorker(SimulatorProcess):
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
assert
NUM_ACTIONS
is
not
None
assert
NUM_ACTIONS
is
not
None
return
[
tf
.
placeholder
(
tf
.
uint8
,
(
None
,)
+
STATE_SHAPE
+
(
FRAME_HISTORY
,
)
,
'state'
),
return
[
tf
.
TensorSpec
((
None
,)
+
STATE_SHAPE
+
(
FRAME_HISTORY
,
),
tf
.
uint8
,
'state'
),
tf
.
placeholder
(
tf
.
int64
,
(
None
,)
,
'action'
),
tf
.
TensorSpec
((
None
,),
tf
.
int64
,
'action'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,)
,
'futurereward'
),
tf
.
TensorSpec
((
None
,),
tf
.
float32
,
'futurereward'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,)
,
'action_prob'
),
tf
.
TensorSpec
((
None
,),
tf
.
float32
,
'action_prob'
),
]
]
def
_get_NN_prediction
(
self
,
state
):
def
_get_NN_prediction
(
self
,
state
):
...
...
examples/CTC-TIMIT/train-timit.py
View file @
ba679ab1
...
@@ -26,11 +26,11 @@ FEATUREDIM = 39 # MFCC feature dimension
...
@@ -26,11 +26,11 @@ FEATUREDIM = 39 # MFCC feature dimension
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
None
,
FEATUREDIM
]
,
'feat'
),
# bxmaxseqx39
return
[
tf
.
TensorSpec
([
None
,
None
,
FEATUREDIM
],
tf
.
float32
,
'feat'
),
# bxmaxseqx39
tf
.
placeholder
(
tf
.
int64
,
[
None
,
None
]
,
'labelidx'
),
# label is b x maxlen, sparse
tf
.
TensorSpec
([
None
,
None
],
tf
.
int64
,
'labelidx'
),
# label is b x maxlen, sparse
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'labelvalue'
),
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'labelvalue'
),
tf
.
placeholder
(
tf
.
int64
,
[
None
]
,
'labelshape'
),
tf
.
TensorSpec
([
None
],
tf
.
int64
,
'labelshape'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'seqlen'
),
# b
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'seqlen'
),
# b
]
]
def
build_graph
(
self
,
feat
,
labelidx
,
labelvalue
,
labelshape
,
seqlen
):
def
build_graph
(
self
,
feat
,
labelidx
,
labelvalue
,
labelshape
,
seqlen
):
...
...
examples/Char-RNN/char-rnn.py
View file @
ba679ab1
...
@@ -70,8 +70,8 @@ class CharRNNData(RNGDataFlow):
...
@@ -70,8 +70,8 @@ class CharRNNData(RNGDataFlow):
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
int32
,
(
None
,
param
.
seq_len
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
param
.
seq_len
),
tf
.
int32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,
param
.
seq_len
)
,
'nextinput'
)]
tf
.
TensorSpec
((
None
,
param
.
seq_len
),
tf
.
int32
,
'nextinput'
)]
def
build_graph
(
self
,
input
,
nextinput
):
def
build_graph
(
self
,
input
,
nextinput
):
cell
=
rnn
.
MultiRNNCell
([
rnn
.
LSTMBlockCell
(
num_units
=
param
.
rnn_size
)
cell
=
rnn
.
MultiRNNCell
([
rnn
.
LSTMBlockCell
(
num_units
=
param
.
rnn_size
)
...
...
examples/DeepQNetwork/DQNModel.py
View file @
ba679ab1
...
@@ -34,12 +34,10 @@ class Model(ModelDesc):
...
@@ -34,12 +34,10 @@ class Model(ModelDesc):
# When we use h history frames, the current state and the next state will have (h-1) overlapping frames.
# When we use h history frames, the current state and the next state will have (h-1) overlapping frames.
# Therefore we use a combined state for efficiency:
# Therefore we use a combined state for efficiency:
# The first h are the current state, and the last h are the next state.
# The first h are the current state, and the last h are the next state.
return
[
tf
.
placeholder
(
self
.
state_dtype
,
return
[
tf
.
TensorSpec
((
None
,)
+
self
.
state_shape
+
(
self
.
history
+
1
,
),
self
.
state_dtype
,
'comb_state'
),
(
None
,)
+
self
.
state_shape
+
(
self
.
history
+
1
,
),
tf
.
TensorSpec
((
None
,),
tf
.
int64
,
'action'
),
'comb_state'
),
tf
.
TensorSpec
((
None
,),
tf
.
float32
,
'reward'
),
tf
.
placeholder
(
tf
.
int64
,
(
None
,),
'action'
),
tf
.
TensorSpec
((
None
,),
tf
.
bool
,
'isOver'
)]
tf
.
placeholder
(
tf
.
float32
,
(
None
,),
'reward'
),
tf
.
placeholder
(
tf
.
bool
,
(
None
,),
'isOver'
)]
@
abc
.
abstractmethod
@
abc
.
abstractmethod
def
_get_DQN_prediction
(
self
,
state
):
def
_get_DQN_prediction
(
self
,
state
):
...
...
examples/DoReFa-Net/resnet-dorefa.py
View file @
ba679ab1
...
@@ -33,8 +33,8 @@ BITG = 32
...
@@ -33,8 +33,8 @@ BITG = 32
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
224
,
224
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
224
,
224
,
3
],
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'label'
)]
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
image
/
256.0
image
=
image
/
256.0
...
...
examples/DoReFa-Net/svhn-digit-dorefa.py
View file @
ba679ab1
...
@@ -41,8 +41,8 @@ BITG = 4
...
@@ -41,8 +41,8 @@ BITG = 4
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
40
,
40
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
40
,
40
,
3
],
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'label'
)]
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
is_training
=
get_current_tower_context
()
.
is_training
is_training
=
get_current_tower_context
()
.
is_training
...
...
examples/DynamicFilterNetwork/steering-filter.py
View file @
ba679ab1
...
@@ -95,10 +95,10 @@ class OnlineTensorboardExport(Callback):
...
@@ -95,10 +95,10 @@ class OnlineTensorboardExport(Callback):
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
)
,
'theta'
),
return
[
tf
.
TensorSpec
((
BATCH
,
),
tf
.
float32
,
'theta'
),
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
SHAPE
,
SHAPE
)
,
'image'
),
tf
.
TensorSpec
((
BATCH
,
SHAPE
,
SHAPE
),
tf
.
float32
,
'image'
),
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
SHAPE
,
SHAPE
)
,
'gt_image'
),
tf
.
TensorSpec
((
BATCH
,
SHAPE
,
SHAPE
),
tf
.
float32
,
'gt_image'
),
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
9
,
9
)
,
'gt_filter'
)]
tf
.
TensorSpec
((
BATCH
,
9
,
9
),
tf
.
float32
,
'gt_filter'
)]
def
_parameter_net
(
self
,
theta
,
kernel_shape
=
9
):
def
_parameter_net
(
self
,
theta
,
kernel_shape
=
9
):
"""Estimate filters for convolution layers
"""Estimate filters for convolution layers
...
...
examples/FasterRCNN/train.py
View file @
ba679ab1
...
@@ -98,14 +98,14 @@ class DetectionModel(ModelDesc):
...
@@ -98,14 +98,14 @@ class DetectionModel(ModelDesc):
class
ResNetC4Model
(
DetectionModel
):
class
ResNetC4Model
(
DetectionModel
):
def
inputs
(
self
):
def
inputs
(
self
):
ret
=
[
ret
=
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
None
,
3
)
,
'image'
),
tf
.
TensorSpec
((
None
,
None
,
3
),
tf
.
float32
,
'image'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,
None
,
cfg
.
RPN
.
NUM_ANCHOR
)
,
'anchor_labels'
),
tf
.
TensorSpec
((
None
,
None
,
cfg
.
RPN
.
NUM_ANCHOR
),
tf
.
int32
,
'anchor_labels'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
None
,
cfg
.
RPN
.
NUM_ANCHOR
,
4
)
,
'anchor_boxes'
),
tf
.
TensorSpec
((
None
,
None
,
cfg
.
RPN
.
NUM_ANCHOR
,
4
),
tf
.
float32
,
'anchor_boxes'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
4
)
,
'gt_boxes'
),
tf
.
TensorSpec
((
None
,
4
),
tf
.
float32
,
'gt_boxes'
),
tf
.
placeholder
(
tf
.
int64
,
(
None
,)
,
'gt_labels'
)]
# all > 0
tf
.
TensorSpec
((
None
,),
tf
.
int64
,
'gt_labels'
)]
# all > 0
if
cfg
.
MODE_MASK
:
if
cfg
.
MODE_MASK
:
ret
.
append
(
ret
.
append
(
tf
.
placeholder
(
tf
.
uint8
,
(
None
,
None
,
None
)
,
'gt_masks'
)
tf
.
TensorSpec
((
None
,
None
,
None
),
tf
.
uint8
,
'gt_masks'
)
)
# NR_GT x height x width
)
# NR_GT x height x width
return
ret
return
ret
...
@@ -199,20 +199,20 @@ class ResNetFPNModel(DetectionModel):
...
@@ -199,20 +199,20 @@ class ResNetFPNModel(DetectionModel):
def
inputs
(
self
):
def
inputs
(
self
):
ret
=
[
ret
=
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
None
,
3
)
,
'image'
)]
tf
.
TensorSpec
((
None
,
None
,
3
),
tf
.
float32
,
'image'
)]
num_anchors
=
len
(
cfg
.
RPN
.
ANCHOR_RATIOS
)
num_anchors
=
len
(
cfg
.
RPN
.
ANCHOR_RATIOS
)
for
k
in
range
(
len
(
cfg
.
FPN
.
ANCHOR_STRIDES
)):
for
k
in
range
(
len
(
cfg
.
FPN
.
ANCHOR_STRIDES
)):
ret
.
extend
([
ret
.
extend
([
tf
.
placeholder
(
tf
.
int32
,
(
None
,
None
,
num_anchors
)
,
tf
.
TensorSpec
((
None
,
None
,
num_anchors
),
tf
.
int32
,
'anchor_labels_lvl{}'
.
format
(
k
+
2
)),
'anchor_labels_lvl{}'
.
format
(
k
+
2
)),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
None
,
num_anchors
,
4
)
,
tf
.
TensorSpec
((
None
,
None
,
num_anchors
,
4
),
tf
.
float32
,
'anchor_boxes_lvl{}'
.
format
(
k
+
2
))])
'anchor_boxes_lvl{}'
.
format
(
k
+
2
))])
ret
.
extend
([
ret
.
extend
([
tf
.
placeholder
(
tf
.
float32
,
(
None
,
4
)
,
'gt_boxes'
),
tf
.
TensorSpec
((
None
,
4
),
tf
.
float32
,
'gt_boxes'
),
tf
.
placeholder
(
tf
.
int64
,
(
None
,)
,
'gt_labels'
)])
# all > 0
tf
.
TensorSpec
((
None
,),
tf
.
int64
,
'gt_labels'
)])
# all > 0
if
cfg
.
MODE_MASK
:
if
cfg
.
MODE_MASK
:
ret
.
append
(
ret
.
append
(
tf
.
placeholder
(
tf
.
uint8
,
(
None
,
None
,
None
)
,
'gt_masks'
)
tf
.
TensorSpec
((
None
,
None
,
None
),
tf
.
uint8
,
'gt_masks'
)
)
# NR_GT x height x width
)
# NR_GT x height x width
return
ret
return
ret
...
...
examples/GAN/BEGAN.py
View file @
ba679ab1
...
@@ -28,7 +28,7 @@ GAMMA = 0.5
...
@@ -28,7 +28,7 @@ GAMMA = 0.5
class
Model
(
GANModelDesc
):
class
Model
(
GANModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
args
.
final_size
,
args
.
final_size
,
3
)
,
'input'
)]
return
[
tf
.
TensorSpec
((
None
,
args
.
final_size
,
args
.
final_size
,
3
),
tf
.
float32
,
'input'
)]
@
auto_reuse_variable_scope
@
auto_reuse_variable_scope
def
decoder
(
self
,
z
):
def
decoder
(
self
,
z
):
...
...
examples/GAN/ConditionalGAN-mnist.py
View file @
ba679ab1
...
@@ -41,8 +41,8 @@ def batch_flatten(x):
...
@@ -41,8 +41,8 @@ def batch_flatten(x):
class
Model
(
GANModelDesc
):
class
Model
(
GANModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
generator
(
self
,
z
,
y
):
def
generator
(
self
,
z
,
y
):
l
=
FullyConnected
(
'fc0'
,
tf
.
concat
([
z
,
y
],
1
),
1024
,
activation
=
BNReLU
)
l
=
FullyConnected
(
'fc0'
,
tf
.
concat
([
z
,
y
],
1
),
1024
,
activation
=
BNReLU
)
...
...
examples/GAN/CycleGAN.py
View file @
ba679ab1
...
@@ -42,8 +42,8 @@ def INLReLU(x, name=None):
...
@@ -42,8 +42,8 @@ def INLReLU(x, name=None):
class
Model
(
GANModelDesc
):
class
Model
(
GANModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
)
,
'inputA'
),
return
[
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
3
),
tf
.
float32
,
'inputA'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
)
,
'inputB'
)]
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
3
),
tf
.
float32
,
'inputB'
)]
@
staticmethod
@
staticmethod
def
build_res_block
(
x
,
name
,
chan
,
first
=
False
):
def
build_res_block
(
x
,
name
,
chan
,
first
=
False
):
...
...
examples/GAN/DCGAN.py
View file @
ba679ab1
...
@@ -41,7 +41,7 @@ class Model(GANModelDesc):
...
@@ -41,7 +41,7 @@ class Model(GANModelDesc):
self
.
zdim
=
z_dim
self
.
zdim
=
z_dim
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
self
.
shape
,
self
.
shape
,
3
)
,
'input'
)]
return
[
tf
.
TensorSpec
((
None
,
self
.
shape
,
self
.
shape
,
3
),
tf
.
float32
,
'input'
)]
def
generator
(
self
,
z
):
def
generator
(
self
,
z
):
""" return an image generated from z"""
""" return an image generated from z"""
...
...
examples/GAN/DiscoGAN-CelebA.py
View file @
ba679ab1
...
@@ -35,8 +35,8 @@ def BNLReLU(x, name=None):
...
@@ -35,8 +35,8 @@ def BNLReLU(x, name=None):
class
Model
(
GANModelDesc
):
class
Model
(
GANModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
)
,
'inputA'
),
return
[
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
3
),
tf
.
float32
,
'inputA'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
)
,
'inputB'
)]
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
3
),
tf
.
float32
,
'inputB'
)]
@
auto_reuse_variable_scope
@
auto_reuse_variable_scope
def
generator
(
self
,
img
):
def
generator
(
self
,
img
):
...
...
examples/GAN/Image2Image.py
View file @
ba679ab1
...
@@ -63,8 +63,8 @@ def visualize_tensors(name, imgs, scale_func=lambda x: (x + 1.) * 128., max_outp
...
@@ -63,8 +63,8 @@ def visualize_tensors(name, imgs, scale_func=lambda x: (x + 1.) * 128., max_outp
class
Model
(
GANModelDesc
):
class
Model
(
GANModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
SHAPE
=
256
SHAPE
=
256
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
IN_CH
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
IN_CH
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
OUT_CH
)
,
'output'
)]
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
OUT_CH
),
tf
.
float32
,
'output'
)]
def
generator
(
self
,
imgs
):
def
generator
(
self
,
imgs
):
# imgs: input: 256x256xch
# imgs: input: 256x256xch
...
...
examples/GAN/InfoGAN-mnist.py
View file @
ba679ab1
...
@@ -106,7 +106,7 @@ def sample_prior(batch_size):
...
@@ -106,7 +106,7 @@ def sample_prior(batch_size):
class
Model
(
GANModelDesc
):
class
Model
(
GANModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input'
)]
return
[
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input'
)]
def
generator
(
self
,
z
):
def
generator
(
self
,
z
):
l
=
FullyConnected
(
'fc0'
,
z
,
1024
,
activation
=
BNReLU
)
l
=
FullyConnected
(
'fc0'
,
z
,
1024
,
activation
=
BNReLU
)
...
...
examples/HED/hed.py
View file @
ba679ab1
...
@@ -103,8 +103,8 @@ def CaffeBilinearUpSample(x, shape):
...
@@ -103,8 +103,8 @@ def CaffeBilinearUpSample(x, shape):
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
None
,
None
,
3
]
,
'image'
),
return
[
tf
.
TensorSpec
([
None
,
None
,
None
,
3
],
tf
.
float32
,
'image'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
,
None
,
None
]
,
'edgemap'
)]
tf
.
TensorSpec
([
None
,
None
,
None
],
tf
.
int32
,
'edgemap'
)]
def
build_graph
(
self
,
image
,
edgemap
):
def
build_graph
(
self
,
image
,
edgemap
):
image
=
image
-
tf
.
constant
([
104
,
116
,
122
],
dtype
=
'float32'
)
image
=
image
-
tf
.
constant
([
104
,
116
,
122
],
dtype
=
'float32'
)
...
...
examples/ImageNetModels/imagenet_utils.py
View file @
ba679ab1
...
@@ -324,8 +324,8 @@ class ImageNetModel(ModelDesc):
...
@@ -324,8 +324,8 @@ class ImageNetModel(ModelDesc):
label_smoothing
=
0.
label_smoothing
=
0.
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
self
.
image_dtype
,
[
None
,
self
.
image_shape
,
self
.
image_shape
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
self
.
image_shape
,
self
.
image_shape
,
3
],
self
.
image_dtype
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'label'
)]
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
self
.
image_preprocess
(
image
)
image
=
self
.
image_preprocess
(
image
)
...
...
examples/ImageNetModels/inception-bn.py
View file @
ba679ab1
...
@@ -23,8 +23,8 @@ INPUT_SHAPE = 224
...
@@ -23,8 +23,8 @@ INPUT_SHAPE = 224
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
INPUT_SHAPE
,
INPUT_SHAPE
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
INPUT_SHAPE
,
INPUT_SHAPE
,
3
],
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'label'
)]
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
image
/
128.0
image
=
image
/
128.0
...
...
examples/OpticalFlow/flownet_models.py
View file @
ba679ab1
...
@@ -145,9 +145,9 @@ class FlowNetBase(ModelDesc):
...
@@ -145,9 +145,9 @@ class FlowNetBase(ModelDesc):
self
.
width
=
width
self
.
width
=
width
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
1
,
3
,
self
.
height
,
self
.
width
)
,
'left'
),
return
[
tf
.
TensorSpec
((
1
,
3
,
self
.
height
,
self
.
width
),
tf
.
float32
,
'left'
),
tf
.
placeholder
(
tf
.
float32
,
(
1
,
3
,
self
.
height
,
self
.
width
)
,
'right'
),
tf
.
TensorSpec
((
1
,
3
,
self
.
height
,
self
.
width
),
tf
.
float32
,
'right'
),
tf
.
placeholder
(
tf
.
float32
,
(
1
,
2
,
self
.
height
,
self
.
width
)
,
'gt_flow'
)]
tf
.
TensorSpec
((
1
,
2
,
self
.
height
,
self
.
width
),
tf
.
float32
,
'gt_flow'
)]
def
graph_structure
(
self
,
inputs
):
def
graph_structure
(
self
,
inputs
):
"""
"""
...
...
examples/PennTreebank/PTB-LSTM.py
View file @
ba679ab1
...
@@ -46,8 +46,8 @@ def get_PennTreeBank(data_dir=None):
...
@@ -46,8 +46,8 @@ def get_PennTreeBank(data_dir=None):
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
int32
,
(
None
,
SEQ_LEN
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
SEQ_LEN
),
tf
.
int32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,
SEQ_LEN
)
,
'nextinput'
)]
tf
.
TensorSpec
((
None
,
SEQ_LEN
),
tf
.
int32
,
'nextinput'
)]
def
build_graph
(
self
,
input
,
nextinput
):
def
build_graph
(
self
,
input
,
nextinput
):
is_training
=
get_current_tower_context
()
.
is_training
is_training
=
get_current_tower_context
()
.
is_training
...
...
examples/ResNet/cifar10-preact18-mixup.py
View file @
ba679ab1
...
@@ -40,8 +40,8 @@ def preactivation_block(input, num_filters, stride=1):
...
@@ -40,8 +40,8 @@ def preactivation_block(input, num_filters, stride=1):
class
ResNet_Cifar
(
ModelDesc
):
class
ResNet_Cifar
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
32
,
32
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
32
,
32
,
3
],
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
float32
,
[
None
,
CLASS_NUM
]
,
'label'
)]
tf
.
TensorSpec
([
None
,
CLASS_NUM
],
tf
.
float32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
assert
tf
.
test
.
is_gpu_available
()
assert
tf
.
test
.
is_gpu_available
()
...
...
examples/ResNet/cifar10-resnet.py
View file @
ba679ab1
...
@@ -39,8 +39,8 @@ class Model(ModelDesc):
...
@@ -39,8 +39,8 @@ class Model(ModelDesc):
self
.
n
=
n
self
.
n
=
n
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
32
,
32
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
32
,
32
,
3
],
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'label'
)]
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
image
/
128.0
image
=
image
/
128.0
...
...
examples/ResNet/load-resnet.py
View file @
ba679ab1
...
@@ -29,8 +29,8 @@ CFG = {
...
@@ -29,8 +29,8 @@ CFG = {
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
224
,
224
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
224
,
224
,
3
],
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'label'
)]
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
blocks
=
CFG
[
DEPTH
]
blocks
=
CFG
[
DEPTH
]
...
...
examples/Saliency/saliency-maps.py
View file @
ba679ab1
...
@@ -54,7 +54,7 @@ def saliency_map(output, input, name="saliency_map"):
...
@@ -54,7 +54,7 @@ def saliency_map(output, input, name="saliency_map"):
class
Model
(
tp
.
ModelDescBase
):
class
Model
(
tp
.
ModelDescBase
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
IMAGE_SIZE
,
IMAGE_SIZE
,
3
)
,
'image'
)]
return
[
tf
.
TensorSpec
((
IMAGE_SIZE
,
IMAGE_SIZE
,
3
),
tf
.
float32
,
'image'
)]
def
build_graph
(
self
,
orig_image
):
def
build_graph
(
self
,
orig_image
):
mean
=
tf
.
get_variable
(
'resnet_v1_50/mean_rgb'
,
shape
=
[
3
])
mean
=
tf
.
get_variable
(
'resnet_v1_50/mean_rgb'
,
shape
=
[
3
])
...
...
examples/SimilarityLearning/mnist-embeddings.py
View file @
ba679ab1
...
@@ -236,9 +236,9 @@ class SiameseModel(EmbeddingModel):
...
@@ -236,9 +236,9 @@ class SiameseModel(EmbeddingModel):
return
ds
return
ds
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input_y'
),
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input_y'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
x
,
y
,
label
):
def
build_graph
(
self
,
x
,
y
,
label
):
# embed them
# embed them
...
@@ -280,9 +280,9 @@ class TripletModel(EmbeddingModel):
...
@@ -280,9 +280,9 @@ class TripletModel(EmbeddingModel):
return
ds
return
ds
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input_p'
),
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input_p'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input_n'
)]
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input_n'
)]
def
loss
(
self
,
a
,
p
,
n
):
def
loss
(
self
,
a
,
p
,
n
):
return
triplet_loss
(
a
,
p
,
n
,
5.
,
extra
=
True
,
scope
=
"loss"
)
return
triplet_loss
(
a
,
p
,
n
,
5.
,
extra
=
True
,
scope
=
"loss"
)
...
@@ -314,8 +314,8 @@ class CenterModel(EmbeddingModel):
...
@@ -314,8 +314,8 @@ class CenterModel(EmbeddingModel):
return
ds
return
ds
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
28
,
28
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
x
,
label
):
def
build_graph
(
self
,
x
,
label
):
# embed them
# embed them
...
...
examples/SpatialTransformer/mnist-addition.py
View file @
ba679ab1
...
@@ -107,8 +107,8 @@ def GridSample(inputs, borderMode='repeat'):
...
@@ -107,8 +107,8 @@ def GridSample(inputs, borderMode='repeat'):
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
,
2
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
IMAGE_SIZE
,
IMAGE_SIZE
,
2
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
xys
=
np
.
array
([(
y
,
x
,
1
)
for
y
in
range
(
WARP_TARGET_SIZE
)
xys
=
np
.
array
([(
y
,
x
,
1
)
for
y
in
range
(
WARP_TARGET_SIZE
)
...
...
examples/SuperResolution/enet-pat.py
View file @
ba679ab1
...
@@ -50,8 +50,8 @@ class Model(GANModelDesc):
...
@@ -50,8 +50,8 @@ class Model(GANModelDesc):
self
.
width
=
width
self
.
width
=
width
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
self
.
height
*
1
,
self
.
width
*
1
,
CHANNELS
)
,
'Ilr'
),
return
[
tf
.
TensorSpec
((
None
,
self
.
height
*
1
,
self
.
width
*
1
,
CHANNELS
),
tf
.
float32
,
'Ilr'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
self
.
height
*
4
,
self
.
width
*
4
,
CHANNELS
)
,
'Ihr'
)]
tf
.
TensorSpec
((
None
,
self
.
height
*
4
,
self
.
width
*
4
,
CHANNELS
),
tf
.
float32
,
'Ihr'
)]
def
build_graph
(
self
,
Ilr
,
Ihr
):
def
build_graph
(
self
,
Ilr
,
Ihr
):
Ilr
,
Ihr
=
Ilr
/
255.0
,
Ihr
/
255.0
Ilr
,
Ihr
=
Ilr
/
255.0
,
Ihr
/
255.0
...
...
examples/basics/cifar-convnet.py
View file @
ba679ab1
...
@@ -29,8 +29,8 @@ class Model(ModelDesc):
...
@@ -29,8 +29,8 @@ class Model(ModelDesc):
self
.
cifar_classnum
=
cifar_classnum
self
.
cifar_classnum
=
cifar_classnum
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
30
,
30
,
3
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
30
,
30
,
3
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
is_training
=
get_current_tower_context
()
.
is_training
is_training
=
get_current_tower_context
()
.
is_training
...
...
examples/basics/export-model.py
View file @
ba679ab1
...
@@ -44,8 +44,8 @@ class Model(ModelDesc):
...
@@ -44,8 +44,8 @@ class Model(ModelDesc):
"""
"""
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
uint8
,
(
None
,
SHAPE
,
SHAPE
,
CHANNELS
)
,
'input_img'
),
return
[
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
CHANNELS
),
tf
.
uint8
,
'input_img'
),
tf
.
placeholder
(
tf
.
uint8
,
(
None
,
SHAPE
,
SHAPE
,
CHANNELS
)
,
'target_img'
)]
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
CHANNELS
),
tf
.
uint8
,
'target_img'
)]
def
make_prediction
(
self
,
img
):
def
make_prediction
(
self
,
img
):
...
@@ -86,7 +86,7 @@ class InferenceOnlyModel(Model):
...
@@ -86,7 +86,7 @@ class InferenceOnlyModel(Model):
def
inputs
(
self
):
def
inputs
(
self
):
# The inference graph only accepts a single image, which is different to the training model.
# The inference graph only accepts a single image, which is different to the training model.
return
[
tf
.
placeholder
(
tf
.
string
,
(
None
,)
,
'input_img_bytes'
)]
return
[
tf
.
TensorSpec
((
None
,),
tf
.
string
,
'input_img_bytes'
)]
def
build_graph
(
self
,
input_img_bytes
):
def
build_graph
(
self
,
input_img_bytes
):
# prepare input (png encoded strings to images)
# prepare input (png encoded strings to images)
...
...
examples/basics/mnist-tflayers.py
View file @
ba679ab1
...
@@ -26,8 +26,8 @@ class Model(ModelDesc):
...
@@ -26,8 +26,8 @@ class Model(ModelDesc):
"""
"""
Define all the inputs (with type, shape, name) that the graph will need.
Define all the inputs (with type, shape, name) that the graph will need.
"""
"""
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
"""This function should build the model which takes the input variables
"""This function should build the model which takes the input variables
...
...
examples/basics/mnist-tfslim.py
View file @
ba679ab1
...
@@ -22,8 +22,8 @@ IMAGE_SIZE = 28
...
@@ -22,8 +22,8 @@ IMAGE_SIZE = 28
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
tf
.
expand_dims
(
image
,
3
)
image
=
tf
.
expand_dims
(
image
,
3
)
...
...
examples/basics/mnist-visualizations.py
View file @
ba679ab1
...
@@ -66,8 +66,8 @@ def visualize_conv_activations(activation, name):
...
@@ -66,8 +66,8 @@ def visualize_conv_activations(activation, name):
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
tf
.
expand_dims
(
image
*
2
-
1
,
3
)
image
=
tf
.
expand_dims
(
image
*
2
-
1
,
3
)
...
...
examples/basics/svhn-digit-convnet.py
View file @
ba679ab1
...
@@ -22,8 +22,8 @@ Each epoch iterates over the whole training set (4721 iterations), and takes abo
...
@@ -22,8 +22,8 @@ Each epoch iterates over the whole training set (4721 iterations), and takes abo
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
40
,
40
,
3
]
,
'input'
),
return
[
tf
.
TensorSpec
([
None
,
40
,
40
,
3
],
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
]
,
'label'
)]
tf
.
TensorSpec
([
None
],
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
image
/
128.0
-
1
image
=
image
/
128.0
-
1
...
...
examples/boilerplate.py
View file @
ba679ab1
...
@@ -19,8 +19,8 @@ CHANNELS = 3
...
@@ -19,8 +19,8 @@ CHANNELS = 3
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
CHANNELS
)
,
'input1'
),
return
[
tf
.
TensorSpec
((
None
,
SHAPE
,
SHAPE
,
CHANNELS
),
tf
.
float32
,
'input1'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'input2'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'input2'
)]
def
build_graph
(
self
,
input1
,
input2
):
def
build_graph
(
self
,
input1
,
input2
):
...
...
examples/keras/mnist-keras.py
View file @
ba679ab1
...
@@ -41,8 +41,8 @@ def get_keras_model():
...
@@ -41,8 +41,8 @@ def get_keras_model():
class
Model
(
ModelDesc
):
class
Model
(
ModelDesc
):
def
inputs
(
self
):
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
)
,
'input'
),
return
[
tf
.
TensorSpec
((
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
tf
.
float32
,
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,)
,
'label'
)]
tf
.
TensorSpec
((
None
,),
tf
.
int32
,
'label'
)]
def
build_graph
(
self
,
image
,
label
):
def
build_graph
(
self
,
image
,
label
):
image
=
tf
.
expand_dims
(
image
,
3
)
*
2
-
1
image
=
tf
.
expand_dims
(
image
,
3
)
*
2
-
1
...
...
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