PyTorch設立計算圖並自動計算(梯度下降和線性迴歸的實現)

numpy和pytorch實現梯度下降法 設定初始值 求取梯度 在梯度方向上進行參數的更新 使用Python實現 x = 1 learning_rate = 0.1 epochs = 100 y = lambda x : x ** 2 + 2 * x + 1 for epoch in range(epochs): dx = 2 * x + 2 x = x - learning_r
相關文章
相關標籤/搜索