modelx = torch.nn.Sequential(*list(modelx.children())[:-1])

时间: 2024-04-08 19:35:28 浏览: 20
你的第一个问题是关于如何使用 PyTorch 将模型的最后一层移除。你可以使用 `torch.nn.Sequential` 类来构建一个新的模型,然后将原始模型的所有子模块(除了最后一层)添加到新模型中。下面是一个示例代码: ```python import torch # 假设原始模型为 modelx modelx = torch.nn.Sequential(*list(modelx.children())[:-1]) # 现在 modelx 中的最后一层已被移除 ``` 使用 `list(modelx.children())[:-1]` 可以获取原始模型的所有子模块(除了最后一层),然后使用 `torch.nn.Sequential` 将这些子模块组合成一个新的模型。
相关问题

如何将self.conv1 = nn.Conv2d(4 * num_filters, num_filters, kernel_size=3, padding=1) self.conv_offset1 = nn.Conv2d(512, 18, kernel_size=3, stride=1, padding=1) init_offset1 = torch.Tensor(np.zeros([18, 512, 3, 3])) self.conv_offset1.weight = torch.nn.Parameter(init_offset1) # 初始化为0 self.conv_mask1 = nn.Conv2d(512, 9, kernel_size=3, stride=1, padding=1) init_mask1 = torch.Tensor(np.zeros([9, 512, 3, 3]) + np.array([0.5])) self.conv_mask1.weight = torch.nn.Parameter(init_mask1) # 初始化为0.5 与torchvision.ops.deform_conv2d,加入到:class NLayerDiscriminator(nn.Module): def init(self, input_nc=3, ndf=64, n_layers=3, norm_layer=nn.BatchNorm2d, use_sigmoid=False, use_parallel=True): super(NLayerDiscriminator, self).init() self.use_parallel = use_parallel if type(norm_layer) == functools.partial: use_bias = norm_layer.func == nn.InstanceNorm2d else: use_bias = norm_layer == nn.InstanceNorm2d kw = 4 padw = int(np.ceil((kw-1)/2)) sequence = [ nn.Conv2d(input_nc, ndf, kernel_size=kw, stride=2, padding=padw), nn.LeakyReLU(0.2, True) ] nf_mult = 1 for n in range(1, n_layers): nf_mult_prev = nf_mult nf_mult = min(2n, 8) sequence += [ nn.Conv2d(ndf * nf_mult_prev, ndf * nf_mult, kernel_size=kw, stride=2, padding=padw, bias=use_bias), norm_layer(ndf * nf_mult), nn.LeakyReLU(0.2, True) ] nf_mult_prev = nf_mult nf_mult = min(2n_layers, 8) sequence += [ nn.Conv2d(ndf * nf_mult_prev, ndf * nf_mult, kernel_size=kw, stride=1, padding=padw, bias=use_bias), norm_layer(ndf * nf_mult), nn.LeakyReLU(0.2, True) ] sequence += [nn.Conv2d(ndf * nf_mult, 1, kernel_size=kw, stride=1, padding=padw)] if use_sigmoid: sequence += [nn.Sigmoid()] self.model = nn.Sequential(*sequence) def forward(self, input): return self.model(input)中,请给出修改后的代码

可以将self.conv1、self.conv_offset1和self.conv_mask1加入到NLayerDiscriminator中的nn.Sequential序列中,如下所示: ``` import torchvision from torchvision.ops.deform_conv import DeformConv2d class NLayerDiscriminator(nn.Module): def __init__(self, input_nc=3, ndf=64, n_layers=3, norm_layer=nn.BatchNorm2d, use_sigmoid=False, use_parallel=True): super(NLayerDiscriminator, self).__init__() self.use_parallel = use_parallel if type(norm_layer) == functools.partial: use_bias = norm_layer.func == nn.InstanceNorm2d else: use_bias = norm_layer == nn.InstanceNorm2d kw = 4 padw = int(np.ceil((kw-1)/2)) nf_mult = 1 sequence = [ nn.Conv2d(input_nc, ndf, kernel_size=kw, stride=2, padding=padw), nn.LeakyReLU(0.2, True) ] for n in range(1, n_layers): nf_mult_prev = nf_mult nf_mult = min(2**n, 8) sequence += [ nn.Conv2d(ndf * nf_mult_prev, ndf * nf_mult, kernel_size=kw, stride=2, padding=padw, bias=use_bias), norm_layer(ndf * nf_mult), nn.LeakyReLU(0.2, True) ] nf_mult_prev = nf_mult nf_mult = min(2**n_layers, 8) sequence += [ DeformConv2d( ndf * nf_mult_prev, ndf * nf_mult, kernel_size=3, stride=1, padding=1, dilation=1, groups=1, deformable_groups=1, bias=False ), norm_layer(ndf * nf_mult), nn.LeakyReLU(0.2, True), nn.Conv2d(ndf * nf_mult, 1, kernel_size=kw, stride=1, padding=padw) ] if use_sigmoid: sequence += [nn.Sigmoid()] self.model = nn.Sequential(*sequence) self.conv1 = nn.Conv2d(4 * ndf, ndf, kernel_size=3, padding=1) self.conv_offset1 = nn.Conv2d(ndf, 18, kernel_size=3, stride=1, padding=1) init_offset1 = torch.Tensor(np.zeros([18, ndf, 3, 3])) self.conv_offset1.weight = torch.nn.Parameter(init_offset1) self.conv_mask1 = nn.Conv2d(ndf, 9, kernel_size=3, stride=1, padding=1) init_mask1 = torch.Tensor(np.zeros([9, ndf, 3, 3]) + np.array([0.5])) self.conv_mask1.weight = torch.nn.Parameter(init_mask1) def forward(self, input): x = input for module in self.model: if isinstance(module, DeformConv2d): offset_mask = torch.cat([self.conv_offset1(x), self.conv_mask1(x)], dim=1) x = module(x, offset_mask) else: x = module(x) return x ``` 这里使用了torchvision.ops.deform_conv2d中的DeformConv2d作为最后一层卷积层,因此需要将self.conv1、self.conv_offset1和self.conv_mask1的通道数修改为ndf。在forward中,对于DeformConv2d层,需要将self.conv_offset1和self.conv_mask1的输出拼接起来作为offset_mask输入。

写出将结构写在一个sequtial中的代码结构与此相同 class CNN(nn.Module): # def __init__(self): # super(CNN, self).__init__() # self.conv1 = nn.Conv2d(3, 32, 3) # self.conv2 = nn.Conv2d(32, 64, 3) # self.conv3 = nn.Conv2d(64, 128, 3) # self.conv4 = nn.Conv2d(128, 256, 3) # self.fc1 = nn.Linear(6400, 1024) # self.fc2 = nn.Linear(1024, 512) # self.fc3 = nn.Linear(512, 128) # self.fc4 = nn.Linear(128, 10) # def forward(self, x): # # 3 x 32 x 32 # x = torch.relu(self.conv1(x)) # 32 x 30 x 30 # x = nn.BatchNorm2d(32).to("cuda")(x) # 32 x 30 x 30 # x = torch.relu(self.conv2(x)) # 64 x 28 x 28 # x = torch.max_pool2d(x, 2) # 64 x 14 x 14 # x = torch.relu(self.conv3(x)) # 128 x 12 x 12 # x = nn.BatchNorm2d(128).to("cuda")(x) # 128 x 12 x 12 # x = torch.relu(self.conv4(x)) # 256 x 10 x 10 # x = torch.max_pool2d(x, 2) # 256 x 5 x 5 # x = x.view(-1, 6400) # x = torch.relu(self.fc1(x)) # x = torch.tanh(self.fc2(x)) # x = torch.relu(self.fc3(x)) # x = self.fc4(x) # return x

以下是将结构写在一个Sequential中的代码: ```python import torch import torch.nn as nn class CNN(nn.Module): def __init__(self): super(CNN, self).__init__() self.model = nn.Sequential( nn.Conv2d(3, 32, 3), nn.ReLU(), nn.BatchNorm2d(32), nn.Conv2d(32, 64, 3), nn.ReLU(), nn.MaxPool2d(2), nn.Conv2d(64, 128, 3), nn.ReLU(), nn.BatchNorm2d(128), nn.Conv2d(128, 256, 3), nn.ReLU(), nn.MaxPool2d(2), nn.Flatten(), nn.Linear(6400, 1024), nn.ReLU(), nn.Linear(1024, 512), nn.Tanh(), nn.Linear(512, 128), nn.ReLU(), nn.Linear(128, 10) ) def forward(self, x): x = self.model(x) return x model = CNN() ``` 在这个代码中,我们使用了`nn.Sequential`来将所有的层组合在一起。每个层都按照从输入到输出的顺序添加到了`nn.Sequential`中。同时,我们也将`nn.BatchNorm2d`和`nn.MaxPool2d`层直接添加到了`nn.Sequential`中。最后,我们在`forward`方法中调用了整个模型。

相关推荐

LDAM损失函数pytorch代码如下:class LDAMLoss(nn.Module): def init(self, cls_num_list, max_m=0.5, weight=None, s=30): super(LDAMLoss, self).init() m_list = 1.0 / np.sqrt(np.sqrt(cls_num_list)) m_list = m_list * (max_m / np.max(m_list)) m_list = torch.cuda.FloatTensor(m_list) self.m_list = m_list assert s > 0 self.s = s if weight is not None: weight = torch.FloatTensor(weight).cuda() self.weight = weight self.cls_num_list = cls_num_list def forward(self, x, target): index = torch.zeros_like(x, dtype=torch.uint8) index_float = index.type(torch.cuda.FloatTensor) batch_m = torch.matmul(self.m_list[None, :], index_float.transpose(1,0)) # 0,1 batch_m = batch_m.view((16, 1)) # size=(batch_size, 1) (-1,1) x_m = x - batch_m output = torch.where(index, x_m, x) if self.weight is not None: output = output * self.weight[None, :] target = torch.flatten(target) # 将 target 转换成 1D Tensor logit = output * self.s return F.cross_entropy(logit, target, weight=self.weight) 模型部分参数如下:# 设置全局参数 model_lr = 1e-5 BATCH_SIZE = 16 EPOCHS = 50 DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') use_amp = True use_dp = True classes = 7 resume = None CLIP_GRAD = 5.0 Best_ACC = 0 #记录最高得分 use_ema=True model_ema_decay=0.9998 start_epoch=1 seed=1 seed_everything(seed) # 数据增强 mixup mixup_fn = Mixup( mixup_alpha=0.8, cutmix_alpha=1.0, cutmix_minmax=None, prob=0.1, switch_prob=0.5, mode='batch', label_smoothing=0.1, num_classes=classes) # 读取数据集 dataset_train = datasets.ImageFolder('/home/adminis/hpy/ConvNextV2_Demo/RAF-DB/RAF/train', transform=transform) dataset_test = datasets.ImageFolder("/home/adminis/hpy/ConvNextV2_Demo/RAF-DB/RAF/valid", transform=transform_test)# 导入数据 train_loader = torch.utils.data.DataLoader(dataset_train, batch_size=BATCH_SIZE, shuffle=True,drop_last=True) test_loader = torch.utils.data.DataLoader(dataset_test, batch_size=BATCH_SIZE, shuffle=False) 帮我用pytorch实现模型在模型训练中使用LDAM损失函数

class MLP(nn.Module): def __init__( self, input_size: int, output_size: int, n_hidden: int, classes: int, dropout: float, normalize_before: bool = True ): super(MLP, self).__init__() self.input_size = input_size self.dropout = dropout self.n_hidden = n_hidden self.classes = classes self.output_size = output_size self.normalize_before = normalize_before self.model = nn.Sequential( nn.Linear(self.input_size, n_hidden), nn.Dropout(self.dropout), nn.ReLU(), nn.Linear(n_hidden, self.output_size), nn.Dropout(self.dropout), nn.ReLU(), ) self.after_norm = torch.nn.LayerNorm(self.input_size, eps=1e-5) self.fc = nn.Sequential( nn.Dropout(self.dropout), nn.Linear(self.input_size, self.classes) ) self.output_layer = nn.Linear(self.output_size, self.classes) def forward(self, x): self.device = torch.device('cuda') # x = self.model(x) if self.normalize_before: x = self.after_norm(x) batch_size, length, dimensions = x.size(0), x.size(1), x.size(2) output = self.model(x) return output.mean(dim=1) class LabelSmoothingLoss(nn.Module): def __init__(self, size: int, smoothing: float, ): super(LabelSmoothingLoss, self).__init__() self.size = size self.criterion = nn.KLDivLoss(reduction="none") self.confidence = 1.0 - smoothing self.smoothing = smoothing def forward(self, x: torch.Tensor, target: torch.Tensor) -> torch.Tensor: batch_size = x.size(0) if self.smoothing == None: return nn.CrossEntropyLoss()(x, target.view(-1)) true_dist = torch.zeros_like(x) true_dist.fill_(self.smoothing / (self.size - 1)) true_dist.scatter_(1, target.view(-1).unsqueeze(1), self.confidence) kl = self.criterion(torch.log_softmax(x, dim=1), true_dist) return kl.sum() / batch_size

import torch from torch import nn from torch.utils.tensorboard import SummaryWriter class MyModule(nn.Module): def __init__(self): super(MyModule, self).__init__() self.model1 = nn.Sequential( nn.Flatten(), nn.Linear(3072, 100), nn.ReLU(), nn.Linear(100, 1), nn.Sigmoid() ) def forward(self, x): x = self.model1(x) return x import torch import torchvision from PIL.Image import Image from torch.utils.tensorboard import SummaryWriter from torch import nn, optim from torch.utils.data import dataloader from torchvision.transforms import transforms from module import MyModule train = torchvision.datasets.CIFAR10(root="../data",train=True, download=True, transform= transforms.ToTensor()) vgg_model = torchvision.models.vgg16(pretrained=True) vgg_model.classifier.add_module('add_linear', nn.Linear(1000,2)) #ToImage = transforms.ToPILImage() #Image.show(ToImage(train[0][0])) train_data = dataloader.DataLoader(train, batch_size = 128, shuffle=True) model = MyModule() #criterion = nn.BCELoss() epochs = 5 learningRate = 1e-3 optimizer = optim.SGD(model.parameters(),lr = learningRate) loss = nn.CrossEntropyLoss() Writer = SummaryWriter(log_dir="Training") step = 0 for epoch in range(epochs): total_loss = 0 for data,labels in train_data: y = vgg_model(data) los = loss(y,labels) optimizer.zero_grad() los.backward() optimizer.step() Writer.add_scalar("Training",los,step) step = step + 1 if step%100 == 0: print("Training for {0} times".format(step)) total_loss += los print("total_loss is {0}".format(los)) Writer.close() torch.save(vgg_model,"model_vgg.pth")修改变成VGG16-两分类模型

class SizeBlock(nn.Module): def __init__(self, conv): super(SizeBlock, self).__init__() self.conv, inc = nc2dc(conv) self.glob = nn.Sequential( nn.Linear(2, 64), nn.ReLU(inplace=True), nn.Linear(64, 32) ) self.local = nn.Sequential( nn.Conv2d(inc, 32, 3, padding=1), nn.ReLU(inplace=True), nn.Conv2d(32, 32, 3, padding=1) ) self.fuse = nn.Sequential( nn.Conv2d(64, 32, 3, padding=1), nn.ReLU(inplace=True), nn.Conv2d(32, 3 * 3 * 2, 3, padding=1) ) self.relu = nn.ReLU() def forward(self, x, bsize): b, c, h, w = x.shape g_offset = self.glob(bsize) g_offset = g_offset.view(b, -1, 1, 1).repeat(1, 1, h, w).contiguous() l_offset = self.local(x) offset = self.fuse(torch.cat((g_offset, l_offset), dim=1)) fea = self.conv(x, offset) return self.relu(fea)和class ResBase(nn.Module): def __init__(self, res_name): super(ResBase, self).__init__() # model_resnet = res_dict[res_name](pretrained=False, norm_layer=BN_2D) model_resnet = res_dict[res_name](pretrained=True) self.sizeblock = SizeBlock self.conv1 = model_resnet.conv1 self.bn1 = model_resnet.bn1 self.relu = model_resnet.relu self.maxpool = model_resnet.maxpool self.layer1 = model_resnet.layer1 self.layer2 = model_resnet.layer2 self.layer3 = model_resnet.layer3 self.layer4 = model_resnet.layer4 self.avgpool = model_resnet.avgpool self.in_features = model_resnet.fc.in_features def forward(self, x, msize): print(x.shape) # torch.Size([8, 3, 384, 384]) x = self.sizeblock(x, msize) x = self.conv1(x) print(x.shape) # torch.Size([8, 64, 192, 192]) x = self.bn1(x) x = self.relu(x) # x = self.self.selist[1](x, msize) x = self.maxpool(x) print(x.shape) # torch.Size([8, 64, 96, 96]) x = self.layer1(x) print(x.shape) # torch.Size([8, 256, 96, 96]) # x = self.self.selist[2](x, msize) x = self.layer2(x) print(x.shape) # torch.Size([8, 512, 48, 48]) # x = self.self.selist[3](x, msize) x = self.layer3(x) # print(x.shape) # torch.Size([8, 1024, 24, 24]) x = self.layer4(x) # print(x.shape) # torch.Size([8, 2048, 12, 12]) x = self.avgpool(x) print(x.shape) # torch.Size([8, 2048, 1, 1]) x = x.view(x.size(0), -1) print(x.shape) # torch.Size([8, 2048]) a = input() return x,如何使用SizeBlock的forward函数

import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable class Bottleneck(nn.Module): def init(self, last_planes, in_planes, out_planes, dense_depth, stride, first_layer): super(Bottleneck, self).init() self.out_planes = out_planes self.dense_depth = dense_depth self.conv1 = nn.Conv2d(last_planes, in_planes, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm2d(in_planes) self.conv2 = nn.Conv2d(in_planes, in_planes, kernel_size=3, stride=stride, padding=1, groups=32, bias=False) self.bn2 = nn.BatchNorm2d(in_planes) self.conv3 = nn.Conv2d(in_planes, out_planes+dense_depth, kernel_size=1, bias=False) self.bn3 = nn.BatchNorm2d(out_planes+dense_depth) self.shortcut = nn.Sequential() if first_layer: self.shortcut = nn.Sequential( nn.Conv2d(last_planes, out_planes+dense_depth, kernel_size=1, stride=stride, bias=False), nn.BatchNorm2d(out_planes+dense_depth) ) def forward(self, x): out = F.relu(self.bn1(self.conv1(x))) out = F.relu(self.bn2(self.conv2(out))) out = self.bn3(self.conv3(out)) x = self.shortcut(x) d = self.out_planes out = torch.cat([x[:,:d,:,:]+out[:,:d,:,:], x[:,d:,:,:], out[:,d:,:,:]], 1) out = F.relu(out) return out class DPN(nn.Module): def init(self, cfg): super(DPN, self).init() in_planes, out_planes = cfg['in_planes'], cfg['out_planes'] num_blocks, dense_depth = cfg['num_blocks'], cfg['dense_depth'] self.conv1 = nn.Conv2d(3, 64, kernel_size=3, stride=1, padding=1, bias=False) self.bn1 = nn.BatchNorm2d(64) self.last_planes = 64 self.layer1 = self._make_layer(in_planes[0], out_planes[0], num_blocks[0], dense_depth[0], stride=1) self.layer2 = self._make_layer(in_planes[1], out_planes[1], num_blocks[1], dense_depth[1], stride=2) self.layer3 = self._make_layer(in_planes[2], out_planes[2], num_blocks[2], dense_depth[2], stride=2) self.layer4 = self._make_layer(in_planes[3], out_planes[3], num_blocks[3], dense_depth[3], stride=2) self.linear = nn.Linear(out_planes[3]+(num_blocks[3]+1)dense_depth[3], 10) def _make_layer(self, in_planes, out_planes, num_blocks, dense_depth, stride): strides = [stride] + 1 layers = [] for i,stride in (strides): layers.append(Bottleneck(self.last_planes, in_planes, out_planes, dense_depth, stride, i==0)) self.last_planes = out_planes + (i+2) * dense_depth return nn.Sequential(*layers) def forward(self, x): out = F.relu(self.bn1(self.conv1(x))) out = self.layer1(out) out = self.layer2(out) out = self.layer3(out) out = self.layer4(out) out = F.avg_pool2d(out, 4) out = out.view(out.size(0), -1) out = self.linear(out) return out def DPN92(): cfg = { 'in_planes': (96,192,384,768), 'out_planes': (256,512,1024,2048), 'num_blocks': (3,4,20,3), 'dense_depth': (16,32,24,128) } return DPN(cfg)基于这个程序改成对摄像头采集的图像检测与分类输出坐标、大小和种类

最新推荐

recommend-type

HP-Socket编译-Linux

HP-Socket编译-Linux
recommend-type

JavaScript_生活在Discord上的开源社区列表.zip

JavaScript
recommend-type

JavaScript_MultiOn API.zip

JavaScript
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

可见光定位LED及其供电硬件具体型号,广角镜头和探测器,实验设计具体流程步骤,

1. 可见光定位LED型号:一般可使用5mm或3mm的普通白色LED,也可以选择专门用于定位的LED,例如OSRAM公司的SFH 4715AS或Vishay公司的VLMU3500-385-120。 2. 供电硬件型号:可以使用常见的直流电源供电,也可以选择专门的LED驱动器,例如Meanwell公司的ELG-75-C或ELG-150-C系列。 3. 广角镜头和探测器型号:一般可采用广角透镜和CMOS摄像头或光电二极管探测器,例如Omron公司的B5W-LA或Murata公司的IRS-B210ST01。 4. 实验设计流程步骤: 1)确定实验目的和研究对象,例如车辆或机器人的定位和导航。
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

实现实时监控告警系统:Kafka与Grafana整合

![实现实时监控告警系统:Kafka与Grafana整合](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2pwZy9BVldpY3ladXVDbEZpY1pLWmw2bUVaWXFUcEdLT1VDdkxRSmQxZXB5R1lxaWNlUjA2c0hFek5Qc3FyRktudFF1VDMxQVl3QTRXV2lhSWFRMEFRc0I1cW1ZOGcvNjQw?x-oss-process=image/format,png) # 1.1 Kafka集群架构 Kafka集群由多个称为代理的服务器组成,这