本文整理汇总了Python中layer.Layer.set_layer方法的典型用法代码示例。如果您正苦于以下问题:Python Layer.set_layer方法的具体用法?Python Layer.set_layer怎么用?Python Layer.set_layer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类layer.Layer
的用法示例。
在下文中一共展示了Layer.set_layer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NormalIntermediateFeature
# 需要导入模块: from layer import Layer [as 别名]
# 或者: from layer.Layer import set_layer [as 别名]
class NormalIntermediateFeature(Filter):
def __init__(self, filter_size, input_size, scales, features, orientations, folder_name, mode):
self.filter_size = filter_size # size of patch
self.input_size = input_size
self.orientations = orientations # number of orientation
self.scales = scales
self.features = features
self.folder_name = folder_name
self.mode = mode
def compute_s2(self, input_layer, output_layer):
class_number = 1
data_number = 1
exi1 = path.isdir(self.folder_name + "/" + str(class_number) + "_" + str(data_number)
+ "_" + str(self.input_size))
print "\n", "normal_s2"
while exi1:
exi2 = path.isdir(self.folder_name + "/" + str(class_number) + "_" + str(data_number)
+ "_" + str(self.input_size))
while exi2:
self.prototype = Layer(self.filter_size, self.scales, self.orientations, "learning_s2",
self.features, self.filter_size, input_layer)
self.prototype.set_layer(self.folder_name, str(class_number) + "_" + str(data_number)
+ "_" + str(self.input_size))
print "feature set " + str(class_number) + "_" + str(data_number)
self.compute_layer(input_layer, output_layer)
data_number += 1
exi2 = path.isdir(self.folder_name + "/" + str(class_number) + "_" + str(data_number)
+ "_" + str(self.input_size))
data_number = 1
class_number += 1
exi1 = path.isdir(self.folder_name + "/" + str(class_number) + "_" + str(data_number)
+ "_" + str(self.input_size))
def compute_unit(self, input_layer, scale, feature, x, y, orientation):
patch = input_layer.get_array(scale)[0, x:x + self.filter_size, y:y + self.filter_size, orientation]
p_patch = self.prototype.get_array(scale)[feature, 0:self.filter_size, 0:self.filter_size, orientation]
alpha = (self.filter_size / 4) ** 2.0
res = np.exp(-np.linalg.norm(p_patch - patch) * 1.0 / (2 * alpha))
return res