1. 查看PyTorch版本
import torch
print(torch.__version__)
![](https://img2020.cnblogs.com/blog/1511168/202004/1511168-20200424065929031-1234577869.png)
2. 模型参数量
model = FPN()
num_params = sum(p.numel() for p in model.parameters())
print("num of params: {:.2f}k".format(num_params/1000.0))
# torch.numel()返回tensor的元素数目,即number of elements
3. 打印模型
model = FPN()
num_params = sum(p.numel() for p in model.parameters())
print("num of params: {:.2f}k".format(num_params/1000.0))
print("===========================")
#for p in model.parameters():
# print(p.name)
print(model)
4. with torch.no_grad()
with torch.no_grad():
# code no gradient Here!
5. 激活函数torch.nn.ReLU(inplace=False)