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
ae9627cf
Commit
ae9627cf
authored
Mar 16, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sed -i 's/InputDesc/tf.placeholder/g;s/_get_inputs/inputs/g' (#318)
parent
39fa4656
Changes
35
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
131 additions
and
125 deletions
+131
-125
examples/A3C-Gym/train-atari.py
examples/A3C-Gym/train-atari.py
+5
-5
examples/CTC-TIMIT/train-timit.py
examples/CTC-TIMIT/train-timit.py
+6
-6
examples/Char-RNN/char-rnn.py
examples/Char-RNN/char-rnn.py
+3
-3
examples/DeepQNetwork/DQNModel.py
examples/DeepQNetwork/DQNModel.py
+8
-8
examples/DoReFa-Net/alexnet-dorefa.py
examples/DoReFa-Net/alexnet-dorefa.py
+3
-3
examples/DoReFa-Net/resnet-dorefa.py
examples/DoReFa-Net/resnet-dorefa.py
+3
-3
examples/DoReFa-Net/svhn-digit-dorefa.py
examples/DoReFa-Net/svhn-digit-dorefa.py
+3
-3
examples/DynamicFilterNetwork/steering-filter.py
examples/DynamicFilterNetwork/steering-filter.py
+5
-5
examples/FasterRCNN/train.py
examples/FasterRCNN/train.py
+7
-7
examples/GAN/BEGAN.py
examples/GAN/BEGAN.py
+2
-2
examples/GAN/ConditionalGAN-mnist.py
examples/GAN/ConditionalGAN-mnist.py
+3
-3
examples/GAN/CycleGAN.py
examples/GAN/CycleGAN.py
+3
-3
examples/GAN/DCGAN.py
examples/GAN/DCGAN.py
+2
-2
examples/GAN/DiscoGAN-CelebA.py
examples/GAN/DiscoGAN-CelebA.py
+3
-3
examples/GAN/Image2Image.py
examples/GAN/Image2Image.py
+3
-3
examples/GAN/InfoGAN-mnist.py
examples/GAN/InfoGAN-mnist.py
+2
-2
examples/HED/hed.py
examples/HED/hed.py
+3
-3
examples/ImageNetModels/imagenet_utils.py
examples/ImageNetModels/imagenet_utils.py
+4
-4
examples/ImageNetModels/inception-bn.py
examples/ImageNetModels/inception-bn.py
+3
-3
examples/PennTreebank/PTB-LSTM.py
examples/PennTreebank/PTB-LSTM.py
+3
-3
examples/ResNet/cifar10-preact18-mixup.py
examples/ResNet/cifar10-preact18-mixup.py
+3
-3
examples/ResNet/cifar10-resnet.py
examples/ResNet/cifar10-resnet.py
+3
-3
examples/ResNet/load-resnet.py
examples/ResNet/load-resnet.py
+3
-3
examples/Saliency/CAM-resnet.py
examples/Saliency/CAM-resnet.py
+3
-3
examples/Saliency/saliency-maps.py
examples/Saliency/saliency-maps.py
+2
-2
examples/SimilarityLearning/mnist-embeddings.py
examples/SimilarityLearning/mnist-embeddings.py
+11
-11
examples/SpatialTransformer/mnist-addition.py
examples/SpatialTransformer/mnist-addition.py
+3
-3
examples/SuperResolution/enet-pat.py
examples/SuperResolution/enet-pat.py
+3
-3
examples/basics/mnist-tflayers.py
examples/basics/mnist-tflayers.py
+3
-3
examples/basics/mnist-tfslim.py
examples/basics/mnist-tfslim.py
+3
-3
examples/basics/mnist-visualizations.py
examples/basics/mnist-visualizations.py
+3
-3
examples/basics/svhn-digit-convnet.py
examples/basics/svhn-digit-convnet.py
+3
-3
examples/boilerplate.py
examples/boilerplate.py
+3
-3
examples/keras/mnist-keras.py
examples/keras/mnist-keras.py
+3
-3
tensorpack/graph_builder/model_desc.py
tensorpack/graph_builder/model_desc.py
+8
-2
No files found.
examples/A3C-Gym/train-atari.py
View file @
ae9627cf
...
...
@@ -69,12 +69,12 @@ class MySimulatorWorker(SimulatorProcess):
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
def
inputs
(
self
):
assert
NUM_ACTIONS
is
not
None
return
[
InputDesc
(
tf
.
uint8
,
(
None
,)
+
IMAGE_SHAPE3
,
'state'
),
InputDesc
(
tf
.
int64
,
(
None
,),
'action'
),
InputDesc
(
tf
.
float32
,
(
None
,),
'futurereward'
),
InputDesc
(
tf
.
float32
,
(
None
,),
'action_prob'
),
return
[
tf
.
placeholder
(
tf
.
uint8
,
(
None
,)
+
IMAGE_SHAPE3
,
'state'
),
tf
.
placeholder
(
tf
.
int64
,
(
None
,),
'action'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,),
'futurereward'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,),
'action_prob'
),
]
def
_get_NN_prediction
(
self
,
image
):
...
...
examples/CTC-TIMIT/train-timit.py
View file @
ae9627cf
...
...
@@ -25,12 +25,12 @@ FEATUREDIM = 39 # MFCC feature dimension
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
None
,
FEATUREDIM
],
'feat'
),
# bxmaxseqx39
InputDesc
(
tf
.
int64
,
[
None
,
None
],
'labelidx'
),
# label is b x maxlen, sparse
InputDesc
(
tf
.
int32
,
[
None
],
'labelvalue'
),
InputDesc
(
tf
.
int64
,
[
None
],
'labelshape'
),
InputDesc
(
tf
.
int32
,
[
None
],
'seqlen'
),
# b
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
None
,
FEATUREDIM
],
'feat'
),
# bxmaxseqx39
tf
.
placeholder
(
tf
.
int64
,
[
None
,
None
],
'labelidx'
),
# label is b x maxlen, sparse
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'labelvalue'
),
tf
.
placeholder
(
tf
.
int64
,
[
None
],
'labelshape'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'seqlen'
),
# b
]
def
_build_graph
(
self
,
inputs
):
...
...
examples/Char-RNN/char-rnn.py
View file @
ae9627cf
...
...
@@ -70,9 +70,9 @@ class CharRNNData(RNGDataFlow):
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
int32
,
(
None
,
param
.
seq_len
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,
param
.
seq_len
),
'nextinput'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
int32
,
(
None
,
param
.
seq_len
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,
param
.
seq_len
),
'nextinput'
)]
def
_build_graph
(
self
,
inputs
):
input
,
nextinput
=
inputs
...
...
examples/DeepQNetwork/DQNModel.py
View file @
ae9627cf
...
...
@@ -6,7 +6,7 @@
import
abc
import
tensorflow
as
tf
import
tensorpack
from
tensorpack
import
ModelDesc
,
InputDesc
from
tensorpack
import
ModelDesc
from
tensorpack.utils
import
logger
from
tensorpack.tfutils
import
(
varreplace
,
summary
,
get_current_tower_context
,
optimizer
,
gradproc
)
...
...
@@ -24,15 +24,15 @@ class Model(ModelDesc):
self
.
num_actions
=
num_actions
self
.
gamma
=
gamma
def
_get_
inputs
(
self
):
def
inputs
(
self
):
# Use a combined state for efficiency.
# The first h channels are the current state, and the last h channels are the next state.
return
[
InputDesc
(
tf
.
uint8
,
return
[
tf
.
placeholder
(
tf
.
uint8
,
(
None
,)
+
self
.
image_shape
+
(
self
.
channel
+
1
,),
'comb_state'
),
InputDesc
(
tf
.
int64
,
(
None
,),
'action'
),
InputDesc
(
tf
.
float32
,
(
None
,),
'reward'
),
InputDesc
(
tf
.
bool
,
(
None
,),
'isOver'
)]
tf
.
placeholder
(
tf
.
int64
,
(
None
,),
'action'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,),
'reward'
),
tf
.
placeholder
(
tf
.
bool
,
(
None
,),
'isOver'
)]
@
abc
.
abstractmethod
def
_get_DQN_prediction
(
self
,
image
):
...
...
examples/DoReFa-Net/alexnet-dorefa.py
View file @
ae9627cf
...
...
@@ -77,9 +77,9 @@ BATCH_SIZE = None
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
224
,
224
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
224
,
224
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/DoReFa-Net/resnet-dorefa.py
View file @
ae9627cf
...
...
@@ -32,9 +32,9 @@ BITG = 32
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
224
,
224
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
224
,
224
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/DoReFa-Net/svhn-digit-dorefa.py
View file @
ae9627cf
...
...
@@ -43,9 +43,9 @@ BITG = 4
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
40
,
40
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
40
,
40
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/DynamicFilterNetwork/steering-filter.py
View file @
ae9627cf
...
...
@@ -95,11 +95,11 @@ class OnlineTensorboardExport(Callback):
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
BATCH
,
),
'theta'
),
InputDesc
(
tf
.
float32
,
(
BATCH
,
SHAPE
,
SHAPE
),
'image'
),
InputDesc
(
tf
.
float32
,
(
BATCH
,
SHAPE
,
SHAPE
),
'gt_image'
),
InputDesc
(
tf
.
float32
,
(
BATCH
,
9
,
9
),
'gt_filter'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
),
'theta'
),
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
SHAPE
,
SHAPE
),
'image'
),
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
SHAPE
,
SHAPE
),
'gt_image'
),
tf
.
placeholder
(
tf
.
float32
,
(
BATCH
,
9
,
9
),
'gt_filter'
)]
def
_parameter_net
(
self
,
theta
,
kernel_shape
=
9
):
"""Estimate filters for convolution layers
...
...
examples/FasterRCNN/train.py
View file @
ae9627cf
...
...
@@ -57,16 +57,16 @@ def get_model_output_names():
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
def
inputs
(
self
):
ret
=
[
InputDesc
(
tf
.
float32
,
(
None
,
None
,
3
),
'image'
),
InputDesc
(
tf
.
int32
,
(
None
,
None
,
config
.
NUM_ANCHOR
),
'anchor_labels'
),
InputDesc
(
tf
.
float32
,
(
None
,
None
,
config
.
NUM_ANCHOR
,
4
),
'anchor_boxes'
),
InputDesc
(
tf
.
float32
,
(
None
,
4
),
'gt_boxes'
),
InputDesc
(
tf
.
int64
,
(
None
,),
'gt_labels'
)]
# all > 0
tf
.
placeholder
(
tf
.
float32
,
(
None
,
None
,
3
),
'image'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,
None
,
config
.
NUM_ANCHOR
),
'anchor_labels'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
None
,
config
.
NUM_ANCHOR
,
4
),
'anchor_boxes'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
4
),
'gt_boxes'
),
tf
.
placeholder
(
tf
.
int64
,
(
None
,),
'gt_labels'
)]
# all > 0
if
config
.
MODE_MASK
:
ret
.
append
(
InputDesc
(
tf
.
uint8
,
(
None
,
None
,
None
),
'gt_masks'
)
tf
.
placeholder
(
tf
.
uint8
,
(
None
,
None
,
None
),
'gt_masks'
)
)
# NR_GT x height x width
return
ret
...
...
examples/GAN/BEGAN.py
View file @
ae9627cf
...
...
@@ -26,8 +26,8 @@ GAMMA = 0.5
class
Model
(
GANModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
args
.
final_size
,
args
.
final_size
,
3
),
'input'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
args
.
final_size
,
args
.
final_size
,
3
),
'input'
)]
@
auto_reuse_variable_scope
def
decoder
(
self
,
z
):
...
...
examples/GAN/ConditionalGAN-mnist.py
View file @
ae9627cf
...
...
@@ -40,9 +40,9 @@ def batch_flatten(x):
class
Model
(
GANModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
generator
(
self
,
z
,
y
):
l
=
FullyConnected
(
'fc0'
,
tf
.
concat
([
z
,
y
],
1
),
1024
,
activation
=
BNReLU
)
...
...
examples/GAN/CycleGAN.py
View file @
ae9627cf
...
...
@@ -41,9 +41,9 @@ def INLReLU(x, name=None):
class
Model
(
GANModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputA'
),
InputDesc
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputB'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputA'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputB'
)]
@
staticmethod
def
build_res_block
(
x
,
name
,
chan
,
first
=
False
):
...
...
examples/GAN/DCGAN.py
View file @
ae9627cf
...
...
@@ -40,8 +40,8 @@ class Model(GANModelDesc):
self
.
batch
=
batch
self
.
zdim
=
z_dim
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
self
.
shape
,
self
.
shape
,
3
),
'input'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
self
.
shape
,
self
.
shape
,
3
),
'input'
)]
def
generator
(
self
,
z
):
""" return an image generated from z"""
...
...
examples/GAN/DiscoGAN-CelebA.py
View file @
ae9627cf
...
...
@@ -34,9 +34,9 @@ def BNLReLU(x, name=None):
class
Model
(
GANModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputA'
),
InputDesc
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputB'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputA'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
3
),
'inputB'
)]
@
auto_reuse_variable_scope
def
generator
(
self
,
img
):
...
...
examples/GAN/Image2Image.py
View file @
ae9627cf
...
...
@@ -63,10 +63,10 @@ def visualize_tensors(name, imgs, scale_func=lambda x: (x + 1.) * 128., max_outp
class
Model
(
GANModelDesc
):
def
_get_
inputs
(
self
):
def
inputs
(
self
):
SHAPE
=
256
return
[
InputDesc
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
IN_CH
),
'input'
),
InputDesc
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
OUT_CH
),
'output'
)]
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
IN_CH
),
'input'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
OUT_CH
),
'output'
)]
def
generator
(
self
,
imgs
):
# imgs: input: 256x256xch
...
...
examples/GAN/InfoGAN-mnist.py
View file @
ae9627cf
...
...
@@ -105,8 +105,8 @@ def sample_prior(batch_size):
class
Model
(
GANModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
)]
def
generator
(
self
,
z
):
l
=
FullyConnected
(
'fc0'
,
z
,
1024
,
activation
=
BNReLU
)
...
...
examples/HED/hed.py
View file @
ae9627cf
...
...
@@ -44,9 +44,9 @@ def class_balanced_sigmoid_cross_entropy(logits, label, name='cross_entropy_loss
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
None
,
None
,
3
],
'image'
),
InputDesc
(
tf
.
int32
,
[
None
,
None
,
None
],
'edgemap'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
None
,
None
,
3
],
'image'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
,
None
,
None
],
'edgemap'
)]
def
_build_graph
(
self
,
inputs
):
image
,
edgemap
=
inputs
...
...
examples/ImageNetModels/imagenet_utils.py
View file @
ae9627cf
...
...
@@ -9,7 +9,7 @@ import multiprocessing
import
tensorflow
as
tf
from
abc
import
abstractmethod
from
tensorpack
import
imgaug
,
dataset
,
ModelDesc
,
InputDesc
from
tensorpack
import
imgaug
,
dataset
,
ModelDesc
from
tensorpack.dataflow
import
(
AugmentImageComponent
,
PrefetchDataZMQ
,
BatchData
,
MultiThreadMapData
)
...
...
@@ -148,9 +148,9 @@ class ImageNetModel(ModelDesc):
def
__init__
(
self
,
data_format
=
'NCHW'
):
self
.
data_format
=
data_format
def
_get_
inputs
(
self
):
return
[
InputDesc
(
self
.
image_dtype
,
[
None
,
self
.
image_shape
,
self
.
image_shape
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
self
.
image_dtype
,
[
None
,
self
.
image_shape
,
self
.
image_shape
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/ImageNetModels/inception-bn.py
View file @
ae9627cf
...
...
@@ -24,9 +24,9 @@ INPUT_SHAPE = 224
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
INPUT_SHAPE
,
INPUT_SHAPE
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
INPUT_SHAPE
,
INPUT_SHAPE
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/PennTreebank/PTB-LSTM.py
View file @
ae9627cf
...
...
@@ -46,9 +46,9 @@ def get_PennTreeBank(data_dir=None):
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
int32
,
(
None
,
SEQ_LEN
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,
SEQ_LEN
),
'nextinput'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
int32
,
(
None
,
SEQ_LEN
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,
SEQ_LEN
),
'nextinput'
)]
def
_build_graph
(
self
,
inputs
):
is_training
=
get_current_tower_context
()
.
is_training
...
...
examples/ResNet/cifar10-preact18-mixup.py
View file @
ae9627cf
...
...
@@ -39,9 +39,9 @@ def preactivation_block(input, num_filters, stride=1):
class
ResNet_Cifar
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
32
,
32
,
3
],
'input'
),
InputDesc
(
tf
.
float32
,
[
None
,
CLASS_NUM
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
32
,
32
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
float32
,
[
None
,
CLASS_NUM
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
assert
tf
.
test
.
is_gpu_available
()
...
...
examples/ResNet/cifar10-resnet.py
View file @
ae9627cf
...
...
@@ -40,9 +40,9 @@ class Model(ModelDesc):
super
(
Model
,
self
)
.
__init__
()
self
.
n
=
n
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
32
,
32
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
32
,
32
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/ResNet/load-resnet.py
View file @
ae9627cf
...
...
@@ -28,9 +28,9 @@ CFG = {
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
224
,
224
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
224
,
224
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/Saliency/CAM-resnet.py
View file @
ae9627cf
...
...
@@ -31,9 +31,9 @@ DEPTH = None
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
uint8
,
[
None
,
INPUT_SHAPE
,
INPUT_SHAPE
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
uint8
,
[
None
,
INPUT_SHAPE
,
INPUT_SHAPE
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/Saliency/saliency-maps.py
View file @
ae9627cf
...
...
@@ -54,8 +54,8 @@ def saliency_map(output, input, name="saliency_map"):
class
Model
(
tp
.
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
t
p
.
InputDesc
(
tf
.
float32
,
(
IMAGE_SIZE
,
IMAGE_SIZE
,
3
),
'image'
)]
def
inputs
(
self
):
return
[
t
f
.
placeholder
(
tf
.
float32
,
(
IMAGE_SIZE
,
IMAGE_SIZE
,
3
),
'image'
)]
def
_build_graph
(
self
,
inputs
):
orig_image
=
inputs
[
0
]
...
...
examples/SimilarityLearning/mnist-embeddings.py
View file @
ae9627cf
...
...
@@ -236,10 +236,10 @@ class SiameseModel(EmbeddingModel):
ds
=
BatchData
(
ds
,
128
//
2
)
return
ds
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input_y'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input_y'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
# get inputs
...
...
@@ -279,10 +279,10 @@ class TripletModel(EmbeddingModel):
ds
=
BatchData
(
ds
,
128
//
3
)
return
ds
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input_p'
),
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input_n'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input_p'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input_n'
)]
def
loss
(
self
,
a
,
p
,
n
):
return
triplet_loss
(
a
,
p
,
n
,
5.
,
extra
=
True
,
scope
=
"loss"
)
...
...
@@ -312,9 +312,9 @@ class CenterModel(EmbeddingModel):
ds
=
BatchData
(
ds
,
128
)
return
ds
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
28
,
28
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
# get inputs
...
...
examples/SpatialTransformer/mnist-addition.py
View file @
ae9627cf
...
...
@@ -20,9 +20,9 @@ HALF_DIFF = (IMAGE_SIZE - WARP_TARGET_SIZE) // 2
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
,
2
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
,
2
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
xys
=
np
.
array
([(
y
,
x
,
1
)
for
y
in
range
(
WARP_TARGET_SIZE
)
...
...
examples/SuperResolution/enet-pat.py
View file @
ae9627cf
...
...
@@ -48,9 +48,9 @@ class Model(GANModelDesc):
self
.
height
=
height
self
.
width
=
width
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
self
.
height
*
1
,
self
.
width
*
1
,
CHANNELS
),
'Ilr'
),
InputDesc
(
tf
.
float32
,
(
None
,
self
.
height
*
4
,
self
.
width
*
4
,
CHANNELS
),
'Ihr'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
self
.
height
*
1
,
self
.
width
*
1
,
CHANNELS
),
'Ilr'
),
tf
.
placeholder
(
tf
.
float32
,
(
None
,
self
.
height
*
4
,
self
.
width
*
4
,
CHANNELS
),
'Ihr'
)]
def
_build_graph
(
self
,
inputs
):
ctx
=
get_current_tower_context
()
...
...
examples/basics/mnist-tflayers.py
View file @
ae9627cf
...
...
@@ -23,13 +23,13 @@ IMAGE_SIZE = 28
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
def
inputs
(
self
):
"""
Define all the inputs (with type, shape, name) that
the graph will need.
"""
return
[
InputDesc
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
"""This function should build the model which takes the input variables
...
...
examples/basics/mnist-tfslim.py
View file @
ae9627cf
...
...
@@ -22,9 +22,9 @@ IMAGE_SIZE = 28
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/basics/mnist-visualizations.py
View file @
ae9627cf
...
...
@@ -68,9 +68,9 @@ def visualize_conv_activations(activation, name):
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
...
...
examples/basics/svhn-digit-convnet.py
View file @
ae9627cf
...
...
@@ -22,9 +22,9 @@ Speed is about 43 it/s on TitanX.
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
[
None
,
40
,
40
,
3
],
'input'
),
InputDesc
(
tf
.
int32
,
[
None
],
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
[
None
,
40
,
40
,
3
],
'input'
),
tf
.
placeholder
(
tf
.
int32
,
[
None
],
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/boilerplate.py
View file @
ae9627cf
...
...
@@ -19,9 +19,9 @@ CHANNELS = 3
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
CHANNELS
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
SHAPE
,
SHAPE
,
CHANNELS
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
examples/keras/mnist-keras.py
View file @
ae9627cf
...
...
@@ -40,9 +40,9 @@ def get_keras_model():
class
Model
(
ModelDesc
):
def
_get_
inputs
(
self
):
return
[
InputDesc
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
InputDesc
(
tf
.
int32
,
(
None
,),
'label'
)]
def
inputs
(
self
):
return
[
tf
.
placeholder
(
tf
.
float32
,
(
None
,
IMAGE_SIZE
,
IMAGE_SIZE
),
'input'
),
tf
.
placeholder
(
tf
.
int32
,
(
None
,),
'label'
)]
def
_build_graph
(
self
,
inputs
):
image
,
label
=
inputs
...
...
tensorpack/graph_builder/model_desc.py
View file @
ae9627cf
...
...
@@ -102,8 +102,10 @@ class ModelDescBase(object):
try
:
return
self
.
_get_inputs
()
except
NotImplementedError
:
with
tf
.
Graph
()
.
as_default
():
# create these placeholder in a temporary graph
with
tf
.
Graph
()
.
as_default
()
as
G
:
# create these placeholder in a temporary graph
inputs
=
self
.
inputs
()
for
p
in
inputs
:
assert
p
.
graph
==
G
,
"Placeholders returned by inputs() sholud be created inside inputs()!"
return
[
InputDesc
.
from_placeholder
(
p
)
for
p
in
inputs
]
def
_get_inputs
(
self
):
...
...
@@ -117,7 +119,11 @@ class ModelDescBase(object):
"""
__Create__ and returns a list of placeholders.
To be implemented by subclass.
The placeholders __have to__ be created inside this function.
The placeholders __have to__ be created inside this method.
Don't return placeholders created in other methods.
You should not call this method by yourself.
Returns:
a list of `tf.placeholder`, to be converted to :class:`InputDesc`.
...
...
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