TFGENZOO.layers.resnet module¶
-
TFGENZOO.layers.resnet.
ShallowConnectedResNet
(inputs: tensorflow.python.keras.engine.input_layer.Input, cond: tensorflow.python.keras.engine.input_layer.Input = None, width: int = 512, out_scale: int = 2, connect_type: str = 'whole')[source]¶ ResNet of OpenAI’s Glow with Connection
- Parameters
inputs (tf.Tensor) – input tensor rank == 4
cond (tf.Tensor) – input tensor rank == 4 (optional)
width (int) – hidden width
out_scale (int) – output channel width scale
- Returns
tf.keras.Model
- Return type
model
Sources:
Examples
>>> inputs = tf.keras.Input([16, 16, 2]) >>> cond = None >>> sr = ShallowConnectedResNet(inputs) >>> sr.summary() Model: "model" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_1 (InputLayer) [(None, 16, 16, 2)] 0 __________________________________________________________________________________________________ conv2d_8 (Conv2D) (None, 16, 16, 512) 10241 input_1[0][0] __________________________________________________________________________________________________ tf_op_layer_Relu_8 (TensorFlowO [(None, 16, 16, 512) 0 conv2d_8[0][0] __________________________________________________________________________________________________ conv2d_9 (Conv2D) (None, 16, 16, 512) 2360321 tf_op_layer_Relu_8[0][0] __________________________________________________________________________________________________ tf_op_layer_Relu_9 (TensorFlowO [(None, 16, 16, 512) 0 conv2d_9[0][0] __________________________________________________________________________________________________ tf_op_layer_concat (TensorFlowO [(None, 16, 16, 514) 0 tf_op_layer_Relu_9[0][0] input_1[0][0] __________________________________________________________________________________________________ conv2d_zeros_4 (Conv2DZeros) (None, 16, 16, 4) 18512 tf_op_layer_concat[0][0] ================================================================================================== Total params: 2,389,074 Trainable params: 2,389,072 Non-trainable params: 2 __________________________________________________________________________________________________ >>> cond = tf.keras.Input([16, 16, 128]) >>> sr = ShallowResNet(inputs, cond, connect_type="cond") >>> sr.summary() sr.summary() Model: "model_4" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_1 (InputLayer) [(None, 16, 16, 2)] 0 __________________________________________________________________________________________________ input_2 (InputLayer) [(None, 16, 16, 128) 0 __________________________________________________________________________________________________ tf_op_layer_concat_3 (TensorFlo [(None, 16, 16, 130) 0 input_1[0][0] input_2[0][0] __________________________________________________________________________________________________ conv2d_14 (Conv2D) (None, 16, 16, 512) 600065 tf_op_layer_concat_3[0][0] __________________________________________________________________________________________________ tf_op_layer_Relu_14 (TensorFlow [(None, 16, 16, 512) 0 conv2d_14[0][0] __________________________________________________________________________________________________ conv2d_15 (Conv2D) (None, 16, 16, 512) 2360321 tf_op_layer_Relu_14[0][0] __________________________________________________________________________________________________ tf_op_layer_Relu_15 (TensorFlow [(None, 16, 16, 512) 0 conv2d_15[0][0] __________________________________________________________________________________________________ tf_op_layer_concat_4 (TensorFlo [(None, 16, 16, 640) 0 tf_op_layer_Relu_15[0][0] input_2[0][0] __________________________________________________________________________________________________ conv2d_zeros_7 (Conv2DZeros) (None, 16, 16, 4) 23048 tf_op_layer_concat_4[0][0] ================================================================================================== Total params: 2,983,434 Trainable params: 2,983,432 Non-trainable params: 2 __________________________________________________________________________________________________
-
TFGENZOO.layers.resnet.
ShallowConnectedResNetlikeSPADE
(inputs: tensorflow.python.keras.engine.input_layer.Input, cond: tensorflow.python.keras.engine.input_layer.Input, width: int = 512, out_scale: int = 2, connect_type: str = 'whole')[source]¶ ResNet of OpenAI’s Glow with Connection .. note:: WIP now…
- Parameters
inputs (tf.Tensor) – input tensor rank == 4
cond (tf.Tensor) – input tensor rank == 4 (optional)
width (int) – hidden width
out_scale (int) – output channel width scale
- Returns
tf.keras.Model
- Return type
model
Sources:
Examples:
-
TFGENZOO.layers.resnet.
ShallowResNet
(inputs: tensorflow.python.keras.engine.input_layer.Input, cond: tensorflow.python.keras.engine.input_layer.Input = None, width: int = 512, out_scale: int = 2)[source]¶ ResNet of OpenAI’s Glow
- Parameters
inputs (tf.Tensor) – input tensor rank == 4
cond (tf.Tensor) – input tensor rank == 4 (optional)
width (int) – hidden width
out_scale (int) – output channel width scale
- Returns
tf.keras.Model
- Return type
model
Sources:
Note
This layer is not Residual Network because this layer does not have Skip connection
Examples
>>> inputs = tf.keras.Input([16, 16, 2]) >>> cond = None >>> sr = ShallowResNet(inputs) >>> sr.summary() Model: "model" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= input_1 (InputLayer) [(None, 16, 16, 2)] 0 _________________________________________________________________ conv2d (Conv2D) (None, 16, 16, 512) 10241 _________________________________________________________________ tf_op_layer_Relu (TensorFlow [(None, 16, 16, 512)] 0 _________________________________________________________________ conv2d_1 (Conv2D) (None, 16, 16, 512) 2360321 _________________________________________________________________ tf_op_layer_Relu_1 (TensorFl [(None, 16, 16, 512)] 0 _________________________________________________________________ conv2d_zeros (Conv2DZeros) (None, 16, 16, 4) 18440 ================================================================= Total params: 2,389,002 Trainable params: 2,389,000 Non-trainable params: 2 _________________________________________________________________ >>> cond = tf.keras.Input([16, 16, 128]) >>> sr = ShallowResNet(inputs, cond) >>> sr.summary() Model: "model_1" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_1 (InputLayer) [(None, 16, 16, 2)] 0 __________________________________________________________________________________________________ input_3 (InputLayer) [(None, 16, 16, 128) 0 __________________________________________________________________________________________________ tf_op_layer_concat_1 (TensorFlo [(None, 16, 16, 130) 0 input_1[0][0] input_3[0][0] __________________________________________________________________________________________________ conv2d_2 (Conv2D) (None, 16, 16, 512) 600065 tf_op_layer_concat_1[0][0] __________________________________________________________________________________________________ tf_op_layer_Relu_2 (TensorFlowO [(None, 16, 16, 512) 0 conv2d_2[0][0] __________________________________________________________________________________________________ conv2d_3 (Conv2D) (None, 16, 16, 512) 2360321 tf_op_layer_Relu_2[0][0] __________________________________________________________________________________________________ tf_op_layer_Relu_3 (TensorFlowO [(None, 16, 16, 512) 0 conv2d_3[0][0] __________________________________________________________________________________________________ conv2d_zeros_1 (Conv2DZeros) (None, 16, 16, 4) 18440 tf_op_layer_Relu_3[0][0] ================================================================================================== Total params: 2,978,826 Trainable params: 2,978,824 Non-trainable params: 2 __________________________________________________________________________________________________