var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
时间: 2023-11-16 19:59:17 浏览: 30
根据提供的引用内容,var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);是一个用于打开应用程序配置文件的方法。它可以让你读取和修改应用程序配置文件中的设置。在引用中,也使用了类似的方法来读取应用程序配置文件中的设置。而引用中的内容则与此无关。
相关问题
def __init__(self, gamma, beta, momentum=0.9, running_mean=None, running_var=None): self.gamma = gamma self.beta = beta self.momentum = momentum self.input_shape = None # Conv层的情况下为4维,全连接层的情况下为2维 # 测试时使用的平均值和方差 self.running_mean = running_mean self.running_var = running_var # backward时使用的中间数据 self.batch_size = None self.xc = None self.std = None self.dgamma = None self.dbeta = None
这是一个Batch Normalization层的类实现。在类的初始化函数中,需要传入该层的缩放因子gamma和偏置beta,并且可以传入动量参数momentum和用于测试时的平均值和方差running_mean和running_var。在前向传播函数中,需要将输入x按照batch进行归一化,并且使用缩放因子gamma和偏置beta进行缩放和平移操作。在反向传播函数中,需要计算出该层的输入梯度dx,以及缩放因子gamma和偏置beta的梯度dgamma和dbeta。最终返回该层的输入梯度dx,以及缩放因子gamma和偏置beta的梯度dgamma和dbeta。其中,中间数据xc表示输入x减去该层的均值mean,std表示该层的标准差,batch_size表示当前batch的大小。
优化代码 var userIdentity = await _userIdentityManager.GetDetail(userId); var staffInfo = await _enterpriseStaffManager.GetDetail(userId); if (userIdentity != null) { infoOutput.IdentityType = userIdentity.IdentityType; infoOutput.IsSelected = userIdentity.IsSelected; } if (staffInfo != null) { infoOutput.Code = staffInfo.EnterpriseCode; infoOutput.UserStatus = EnterpriseUserStatus.Authenticated; infoOutput.Level = (AppStaffLevelType)staffInfo.Level; } else { var curCreate = await _applicationManager.GetCreate(userId); var auditInfo = await _enterpriseAuditManager.GetNewAuditData(userId); infoOutput.UserStatus = GetAuditStateType(auditInfo); if (curCreate != null) { if (curCreate.Status == EnterpriseCreationApplicationStatus.UnderReview) { infoOutput.UserStatus = EnterpriseUserStatus.CreateAudit; } else if (auditInfo?.AuditState == EnterpriseAuditStateType.EmployeeRejected && curCreate.UpdatedDate > auditInfo?.UpdatedDate) { infoOutput.UserStatus = EnterpriseUserStatus.CreateFail; } } }
You can optimize the code by using the null-conditional operator (?.) and the null-coalescing operator (??) to simplify the nested if statements and reduce the amount of duplicated code. Here's an example:
```
var userIdentity = await _userIdentityManager.GetDetail(userId);
var staffInfo = await _enterpriseStaffManager.GetDetail(userId);
infoOutput.IdentityType = userIdentity?.IdentityType;
infoOutput.IsSelected = userIdentity?.IsSelected;
if (staffInfo != null)
{
infoOutput.Code = staffInfo.EnterpriseCode;
infoOutput.UserStatus = EnterpriseUserStatus.Authenticated;
infoOutput.Level = (AppStaffLevelType)staffInfo.Level;
}
else
{
var curCreate = await _applicationManager.GetCreate(userId);
var auditInfo = await _enterpriseAuditManager.GetNewAuditData(userId);
infoOutput.UserStatus = GetAuditStateType(auditInfo) ??
(curCreate?.Status == EnterpriseCreationApplicationStatus.UnderReview ?
EnterpriseUserStatus.CreateAudit :
(auditInfo?.AuditState == EnterpriseAuditStateType.EmployeeRejected && curCreate.UpdatedDate > auditInfo?.UpdatedDate ?
EnterpriseUserStatus.CreateFail :
infoOutput.UserStatus));
}
```
This code first uses the null-conditional operator to check if `userIdentity` is not null before setting the properties of `infoOutput`. Then, it checks if `staffInfo` is not null to set the remaining properties of `infoOutput`. If `staffInfo` is null, it uses the null-coalescing operator to check if `auditInfo` is not null and call `GetAuditStateType` to determine the user status. If `auditInfo` is null, it checks if `curCreate` is not null and if its status is `UnderReview` to set the user status to `CreateAudit`. If `auditInfo` is not null, it checks if its `AuditState` is `EmployeeRejected` and if `curCreate` has been updated since the last audit date to set the user status to `CreateFail`. If none of these conditions are met, it keeps the current user status.