Pytorch 6

罗切斯特回归模型

加了激活函数

加了激活函数之后类

python 复制代码
class LogisticRegressionModel(torch.nn.Module):
    def __init__(self):
        super(LogisticRegressionModel, self).__init__()
        self.linear = torch.nn.Linear(1,1)
 
    def forward(self, x):
        # y_pred = F.sigmoid(self.linear(x))
        y_pred = torch.sigmoid(self.linear(x))
        return y_pred

这里以sigmoid激活函数为例,具体的激活函数还是查资料

损失函数

python 复制代码
criterion = torch.nn.BCELoss(size_average = False) 

也是接受一个参数,是否求平均值

求平均值会影响到dw和db是否要乘1/n,会影响到学习率的设置,如果求均值则偏导也有1/n

相关推荐
东离与糖宝14 小时前
教育智能体基础:个性化教学、答疑、出题、批改
人工智能
阿洛学长14 小时前
闲鱼智能监控机器人:开源 AI 闲鱼多任务实时监控工具,可视化管理与精准筛选
人工智能·机器人·开源
姜太小白14 小时前
【Linux】CentOS 7 VNC 远程桌面配置
linux·python·centos
Ai.den14 小时前
Windows 安装 DeerFlow 2.0
人工智能·windows·python·ai
Legend NO2414 小时前
从“看报表”到“对话决策”:AI正在重构数据分析体系
大数据·人工智能
BBTSOH1590151604414 小时前
VR每日简报2026.4.14
人工智能·机器人·vr·具身智能·人形机器人·机械手·遥操作
MPY_314 小时前
Windsurf API Proxy - AI 模型统一访问平台
人工智能
山海AI手册14 小时前
028、边缘AI与嵌入式部署:TensorFlow Lite/PyTorch Mobile实战手记
人工智能·pytorch·tensorflow
weixin_4331793314 小时前
python - 存储数据
python
程序员cxuan14 小时前
36 张图彻底解释清楚 AI 圈 136 个造词艺术!!!
人工智能·后端·github copilot