python - 需要帮助解决问题 ''AttributeError: 'function' object has no attribute 'summary'''
问题描述
需要帮助解决问题'AttributeError: 'function' object has no attribute 'summary'
。
def model(inputs):
batch_size,height,width=config.BATCH_SIZE,config.IMAGE_SHAPE[0],config.IMAGE_SHAPE[1]
with slim.arg_scope(resnet_v2.resnet_arg_scope()):
#net, end_points = resnet_v2.resnet_v2_101(inputs, 1001, is_training=False)
net, end_points = resnet_v2.resnet_v2_152(inputs,
2048,
is_training=True,
global_pool=False,
reuse=tf.AUTO_REUSE,
output_stride=config.OUTPUT_STRIDE)
#print(net)
kp_maps = tf.contrib.layers.conv2d(net,num_outputs = config.NUM_KP,
kernel_size=(1,1),activation_fn=tf.nn.sigmoid,stride=1,scope='kp_maps',reuse=tf.AUTO_REUSE)
short_offsets = tf.contrib.layers.conv2d(net,num_outputs = 2*config.NUM_KP,
kernel_size=(1,1),activation_fn=None,stride=1,scope='short_offsets',reuse=tf.AUTO_REUSE)
mid_offsets = tf.contrib.layers.conv2d(net,num_outputs = 4*config.NUM_EDGES,
kernel_size=(1,1),activation_fn=None,stride=1,scope='mid_offsets',reuse=tf.AUTO_REUSE)
long_offsets = tf.contrib.layers.conv2d(net,num_outputs = 2*config.NUM_KP,
kernel_size=(1,1),activation_fn=None,stride=1,scope='long_offsets',reuse=tf.AUTO_REUSE)
seg_mask = tf.contrib.layers.conv2d(net,num_outputs = 1,
kernel_size=(1,1),activation_fn=tf.nn.sigmoid,stride=1,scope='seg_mask',reuse=tf.AUTO_REUSE)
model.summary()
我正在尝试打印模型的摘要
解决方案
模型中似乎model.summary()
是对当前函数的引用。
您正在尝试使用递归函数引用。
尝试将模型引用与输入一起传递给此函数并使用它来获取摘要。
def model(model_obj, inputs):
...
model_obj.summary()
推荐阅读
- python - Python Spyder:如何注释代码的特定部分?
- html - 在两个没有固定高度的 div 中间覆盖 div
- java - Base 64 是否会导致数据重复?
- csv - 将 pcap 文件导出到包含所有信息的 csv 中
- ios - 无法更改 iOS14 小部件背景颜色
- vba - 将包含零星使用引号的 .CSV 文件导入 MS Access
- typescript - 打字稿:if(variable),if(!variable)和if(!variable)有什么区别?
- ssl - 如何使用 cURL 或 Postman 在 Haproxy 中测试 SSL 身份验证?
- python - 在 Django Admin 中更改标签的 CSS
- javascript - 在 iframe 中添加画布 (fabric.js) 时出现问题