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

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.

主站蜘蛛池模板: 德清县| 黄陵县| 棋牌| 焉耆| 镶黄旗| 阿拉善盟| 沾益县| 肥东县| 威信县| 凤台县| 丰县| 辰溪县| 临猗县| 商河县| 新泰市| 永仁县| 井陉县| 鄂伦春自治旗| 阿勒泰市| 耿马| 涟水县| 株洲县| 河南省| 宁明县| 麻阳| 文水县| 松阳县| 泰州市| 海林市| 汕尾市| 濮阳市| 樟树市| 固阳县| 凤山市| 比如县| 北海市| 寿光市| 招远市| 武清区| 大埔县| 兴隆县|