grouping expressions sequence is empty, and 'c.pay_ord_amt_tb' is not an aggregate function.
时间: 2024-04-21 08:26:24 浏览: 207
这是一个 SQL 报错信息,它的意思是:在一个 GROUP BY 子句中,分组表达式的值为空,并且 'c.pay_ord_amt_tb' 不是聚合函数。
解决这个问题需要检查 GROUP BY 子句中的分组表达式是否正确,以及查询中是否正确使用了聚合函数。可能需要检查查询中的其他部分,如 SELECT、FROM、WHERE 子句等,以查找问题的根本原因。
相关问题
for k in range(cfg.RPN.SA_CONFIG.NPOINTS.__len__()): mlps = cfg.RPN.SA_CONFIG.MLPS[k].copy() channel_out = 0 for idx in range(mlps.__len__()): mlps[idx] = [channel_in] + mlps[idx] channel_out += mlps[idx][-1] self.SA_modules.append( PointnetSAModuleMSG( npoint=cfg.RPN.SA_CONFIG.NPOINTS[k], radii=cfg.RPN.SA_CONFIG.RADIUS[k], nsamples=cfg.RPN.SA_CONFIG.NSAMPLE[k], mlps=mlps, use_xyz=use_xyz, bn=cfg.RPN.USE_BN ) ) skip_channel_list.append(channel_out) channel_in = channel_out self.FP_modules = nn.ModuleList() for k in range(cfg.RPN.FP_MLPS.__len__()): pre_channel = cfg.RPN.FP_MLPS[k + 1][-1] if k + 1 < len(cfg.RPN.FP_MLPS) else channel_out self.FP_modules.append( PointnetFPModule(mlp=[pre_channel + skip_channel_list[k]] + cfg.RPN.FP_MLPS[k]) ) def _break_up_pc(self, pc): xyz = pc[..., 0:3].contiguous() features = ( pc[..., 3:].transpose(1, 2).contiguous() if pc.size(-1) > 3 else None ) return xyz, features def forward(self, pointcloud: torch.cuda.FloatTensor): xyz, features = self._break_up_pc(pointcloud) l_xyz, l_features = [xyz], [features] for i in range(len(self.SA_modules)): li_xyz, li_features = self.SA_modules[i](l_xyz[i], l_features[i]) l_xyz.append(li_xyz) l_features.append(li_features) for i in range(-1, -(len(self.FP_modules) + 1), -1): l_features[i - 1] = self.FP_modules[i]( l_xyz[i - 1], l_xyz[i], l_features[i - 1], l_features[i] ) return l_xyz[0], l_features[0]在forward函数中,如果我要使用channel_out变量传入SA_modules中,我该如何在forward函数中计算并得到它,再传入SA_modules中,你可以给我详细的代码吗?
在 forward 函数中,可以定义一个变量 channel_out,用于保存当前 SA_module 的输出通道数。然后在每一次循环时更新 channel_out 的值,并将其传入 SA_module 中。代码如下:
```
def forward(self, pointcloud: torch.cuda.FloatTensor):
xyz, features = self._break_up_pc(pointcloud)
l_xyz, l_features = [xyz], [features]
channel_out = 0 # 初始化 channel_out
for i in range(len(self.SA_modules)):
mlps = self.SA_modules[i].mlps # 获取当前 SA_module 的 MLPs
# 计算当前 SA_module 的输出通道数
channel_out = sum(mlp[-1] for mlp in mlps)
li_xyz, li_features = self.SA_modules[i](
l_xyz[i], l_features[i], channel_out=channel_out # 传入 channel_out
)
l_xyz.append(li_xyz)
l_features.append(li_features)
for i in range(-1, -(len(self.FP_modules) + 1), -1):
l_features[i - 1] = self.FP_modules[i](
l_xyz[i - 1], l_xyz[i], l_features[i - 1], l_features[i]
)
return l_xyz[0], l_features[0]
```
在 SA_module 的 forward 函数中,需要修改函数签名,增加一个参数 channel_out,用于指定输出通道数。然后在函数中使用该参数来初始化 MLP 中的第一个元素。代码如下:
```
class PointnetSAModuleMSG(nn.Module):
def __init__(self, npoint, radii, nsamples, mlps, use_xyz=True, bn=True):
super(PointnetSAModuleMSG, self).__init__()
self.npoint = npoint
self.radii = radii
self.nsamples = nsamples
self.bn = bn
self.use_xyz = use_xyz
self.SA_modules = nn.ModuleList()
for j in range(len(mlps)):
in_channel = mlps[j][0]
mlp = nn.Sequential()
for k in range(len(mlps[j])-1):
mlp.add_module('layer{}'.format(k),
pt_utils.Conv1d(in_channel, mlps[j][k+1], bn=self.bn))
in_channel = mlps[j][k+1]
self.SA_modules.append(mlp)
def forward(self, xyz, features, channel_out):
if self.use_xyz:
new_features_list = [xyz.transpose(1, 2)]
else:
new_features_list = []
for i in range(len(self.radii)):
idx, pts_cnt = pt_utils.query_ball_point(self.radii[i], self.nsamples[i], xyz, xyz)
grouped_xyz = pt_utils.grouping_operation(xyz, idx)
grouped_xyz -= xyz.unsqueeze(-1)
if features is not None:
grouped_features = pt_utils.grouping_operation(features, idx)
grouped_features = torch.cat([grouped_features, grouped_xyz], dim=1)
else:
grouped_features = grouped_xyz
new_features = self.SA_modules[i](grouped_features)
new_features = new_features.max(dim=-1)[0]
new_features_list.append(new_features)
new_features = torch.cat(new_features_list, dim=1)
for i in range(len(self.SA_modules)):
new_features[:, i:i+1] = self.SA_modules[i][0](new_features[:, i:i+1]) # 初始化 MLP 中的第一个元素
if channel_out != new_features.size(1): # 如果输出通道数不一致,进行升维或降维
new_features = pt_utils.Conv1d(new_features.size(1), channel_out, bn=self.bn)(new_features)
new_xyz = pt_utils.gather_operation(xyz, pt_utils.furthest_point_sample(xyz, self.npoint))
return new_xyz, new_features
```
优化一下代码 JSONObject typeObj = new JSONObject(); Map<String, Integer> typeMap = new HashMap<>(); typeMap.put(SpecialWorkType.FIRE_WORK.desc, 0); typeMap.put(SpecialWorkType.CONFINED_WORK.desc, 0); typeMap.put(SpecialWorkType.MAINTENANCE_WORK.desc, 0); typeMap.put(SpecialWorkType.HIGH_WORK.desc, 0); typeMap.put(SpecialWorkType.LIFTING_WORK.desc, 0); typeMap.put(SpecialWorkType.ELECTRICIAN_WORK.desc, 0); typeMap.put(SpecialWorkType.LAND_WORK.desc, 0); typeMap.put(SpecialWorkType.ROAD_WORK.desc, 0); specialOperations.forEach(v -> { Integer domainCount = domainMap.get(v.getDomainId()); if (domainCount == null) { domainMap.put(v.getDomainId(), 1); } else { domainMap.put(v.getDomainId(), ++domainCount); } Integer typeCount = typeMap.get(v.getJobType().desc); typeMap.put(v.getJobType().desc, ++typeCount); });
可以尝试使用更简洁的方式来优化这段代码,如下所示:
```
Map<Long, Integer> domainMap = specialOperations.stream()
.collect(Collectors.groupingBy(SpecialOperation::getDomainId, Collectors.summingInt(e -> 1)));
Map<String, Integer> typeMap = specialOperations.stream()
.collect(Collectors.groupingBy(v -> v.getJobType().desc, Collectors.summingInt(e -> 1)));
```
这里使用了Java 8引入的Stream API,利用 `Collectors.groupingBy()` 方法将特定属性相同的对象进行分组,并使用 `Collectors.summingInt()` 方法进行计数。这样可以简化代码,并提高代码的可读性和可维护性。
阅读全文