You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class ModelObj: # 网络对象
def __init__(self, ObjID, ObjType, ObjLable, ParaString, ObjX, ObjY):
self.ObjID = ObjID # 图元号
self.ObjType = ObjType # 图元类别
self.ObjLable = ObjLable # 对象标签
self.ParaString = ParaString # 参数字符串
self.ObjX = ObjX # 对象位置x坐标
self.ObjY = ObjY # 对象位置y坐标
class Conv_Class(ModelObj): # 卷积对象
def __init__(self, ObjID, ObjType, ObjLable, ParaString, ObjX, ObjY):
super().__init__(ObjID, ObjType, ObjLable, ParaString, ObjX, ObjY)
self.ConvProc = self.conv_proc # 基本操作函数
self.SetConvPara = self.setconv_para # 参数设置函数
def setconv_para(self): # 定义设置卷积参数的函数SetConvPara()
kernel_h = int(input("请输入卷积核的高度: ")) # 用户输入卷积核的高度
kernel_w = int(input("请输入卷积核的宽度: ")) # 用户输入卷积核的宽度
# 用户输入卷积核的值
kernel = []
print("请输入卷积核的值:")
for i in range(kernel_h):
row = [float(val) for val in input().split()]
kernel.append(row)
stride = int(input("请输入步长: ")) # 用户输入步长
padding = int(input("请输入填充: ")) # 用户输入填充
# 返回ConvPara参数这里用一个字典来存储
ConvPara = {"kernel": kernel, "kernel_h": kernel_h,
"kernel_w": kernel_w, "stride": stride,
"padding": padding}
return ConvPara
if __name__ == '__main__':
Conv = Conv_Class("Conv1", 2, "卷积1", [], 250, 330)
ConvPara = Conv.SetConvPara()
print(ConvPara)