keras_resnet.models.ResNet50样例

import tensorflow as tf
import keras_resnet.models
import numpy as np
import keras

x = np.ones([1, 239, 224, 3])
inputs = keras.layers.Input(shape=(None, None, 3))
resnet = keras_resnet.models.ResNet50(inputs, include_top=False, freeze_bn=True)
y = resnet.outputs[1:]

with tf.Session() as sess:
    init = tf.global_variables_initializer()
    sess.run(init)
    z = sess.run(y, feed_dict={inputs: x})
    C3, C4, C5 = z
    print('C3: ',np.shape(C3))
    print('C4: ',np.shape(C4))
    print('C5: ',np.shape(C5))
'''
结果:
C3:  (1, 30, 28, 512)
C4:  (1, 15, 14, 1024)
C5:  (1, 8, 7, 2048)
'''

x换成np.ones([1, 224, 224, 3])时,结果为

C3:  (1, 28, 28, 512)
C4:  (1, 14, 14, 1024)
C5:  (1, 7, 7, 2048)

x换成np.ones([1, 500, 500, 3])时,结果为

C3:  (1, 63, 63, 512)
C4:  (1, 32, 32, 1024)
C5:  (1, 16, 16, 2048)

由此看出keras_resnet.models.ResNet50这个model的输入应该并不固定。

猜你喜欢

转载自blog.csdn.net/weixin_43331915/article/details/83316202
今日推荐