Skip to content

Commit 71f2370

Browse files
committed
Merge pull request #857 from LupusSanctus:am/tf_reshape
2 parents e7fb489 + 6f3fd2e commit 71f2370

7 files changed

+11
-2
lines changed

testdata/dnn/tensorflow/generate_tf_models.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import cv2 as cv
66
import numpy as np
77
import tensorflow as tf
8+
from tensorflow import keras as K
89
from tensorflow.python.tools import optimize_for_inference_lib
910
from tensorflow.tools.graph_transforms import TransformGraph
1011

@@ -405,6 +406,16 @@ def my_dropout(x):
405406
mm = tf.matmul(flattened, weights) + biases
406407
save(inp, flattened, 'nhwc_transpose_reshape_matmul')
407408
################################################################################
409+
inp = tf.placeholder(tf.float32, [1, 24], 'input')
410+
# tf Reshape layer automatically adds 1 to the shape => (1, 2, 4, 3)
411+
out = K.layers.Reshape((2, 4, 3), name="reshape")(inp)
412+
save(inp, out, 'reshape_layer')
413+
################################################################################
414+
inp = tf.placeholder(tf.float32, [1, 3, 3, 4], 'input')
415+
conv2 = tf.layers.conv2d(inp, filters=4, kernel_size=1)
416+
out = tf.reshape(conv2, [1, 2, 3, 6], 'reshaped')
417+
save(inp, out, 'reshape_nchw')
418+
################################################################################
408419
inp = tf.placeholder(tf.float32, [1, 6, 5, 3], 'input')
409420
conv = tf.layers.conv2d(inputs=inp, filters=3, kernel_size=[1, 1],
410421
activation=tf.nn.relu,
@@ -512,8 +523,6 @@ def my_dropout(x):
512523
relu = tf.maximum(0.01 * inp, inp, name='leaky_relu') * 2
513524
save(inp, relu, 'leaky_relu_order3', optimize=False)
514525
################################################################################
515-
from tensorflow import keras as K
516-
517526
model = K.models.Sequential()
518527
model.add(K.layers.Softmax(name='keras_softmax', input_shape=(2, 3, 4)))
519528
sess = K.backend.get_session()
224 Bytes
Binary file not shown.
245 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.
272 Bytes
Binary file not shown.
738 Bytes
Binary file not shown.
272 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)