官术网_书友最值得收藏!

Network implementation 

As we have all the parameters (x, w, b, and y) required to implement the network, we perform a matrix multiplication between w and x. Then, sum the result with b. That will give our predicted y. The function is implemented as follows:

def simple_network(x):
y_pred = torch.matmul(x,w)+b
return y_pred

PyTorch also provides a higher-level abstraction in torch.nn called layers, which will take care of most of these underlying initialization and operations associated with most of the common techniques available in the neural network. We are using the lower-level operations to understand what happens inside these functions. In later chapters, that is Chapter 5, Deep Learning for Computer Vision and Chapter 6, Deep Learning with Sequence Data and Text, we will be relying on the PyTorch abstractions to build complex neural networks or functions. The previous model can be represented as a torch.nn layer, as follows:

f = nn.Linear(17,1) # Much simpler.

Now that we have calculated the y values, we need to know how good our model is, which is done in the loss function.

主站蜘蛛池模板: 石泉县| 深水埗区| 湖南省| 中牟县| 即墨市| 龙南县| 繁峙县| 海伦市| 城市| 鹤峰县| 德惠市| 湟中县| 乐山市| 安陆市| 阿尔山市| 兴隆县| 霍林郭勒市| 社会| 马尔康县| 静安区| 观塘区| 周宁县| 古蔺县| 塔城市| 长宁区| 汝州市| 安化县| 沐川县| 敦煌市| 岳西县| 宁南县| 永嘉县| 高州市| 弥勒县| 汉阴县| 姚安县| 岳阳市| 永城市| 南宁市| 长丰县| 广德县|