gpt4 book ai didi

python - 属性错误: module 'tensorflow' has no attribute 'batch_matrix_band_part'

转载 作者:太空宇宙 更新时间:2023-11-03 15:23:13 24 4
gpt4 key购买 nike

我尝试解决这个网站中的练习 Convolutional Neural Networks

练习是:

The model architecture in inference() differs slightly from the CIFAR-10 model specified in cuda-convnet. In particular, the top layers of Alex's original model are locally connected and not fully connected. Try editing the architecture to exactly reproduce the locally connected architecture in the top layer.

我尝试在 inference():: 最后部分的 cifar10.py 中添加 (batch_matrix_band_part) 函数

with tf.variable_scope('softmax_linear') as scope:
weights = _variable_with_weight_decay('weights', [192, NUM_CLASSES],
stddev=1/192.0, wd=0.0)
biases = _variable_on_cpu('biases', [NUM_CLASSES],
tf.constant_initializer(0.0))
##softmax_linear = tf.add(tf.matmul(local4, weights), biases, name=scope.name) ## fully connection layer

WeightTemp = tf.batch_matrix_band_part(weights, -1, 1, name=None) ##using band matrix to be locally connected
## tf.batch_matrix_band_part(input, num_lower, num_upper, name=None)
softmax_linear= tf.add(tf.matmul(local4, weightTemp), biases, name-scope.name)
tf.nn.softmax(softmax_linear, dim=-1, name=None) ## for normalize the logits
_activation_summary(softmax_linear)
return softmax_linear

但这给了我这个错误::

AttributeError: module 'tensorflow' has no attribute 'batch_matrix_band_part'

有什么办法可以解决这个问题吗?

最佳答案

正如错误所说 - tensorflow 没有名为 batch_matrix_band_part 的方法。相反,使用 tf.matrix_band_part

关于python - 属性错误: module 'tensorflow' has no attribute 'batch_matrix_band_part' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43353862/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com