P1007. 独木桥

题目描述

当两人面对面相碰时,两人都会转向行走, 那可以看成两个人交错而过。

求最小时间,计算出每个人到达两边的最小时间,所有时间中最大的一个即为所有人离开桥需要用的时间。

求最大时间,计算出每个人到达两边的最大时间,所有时间中最大的一个即为所有人离开桥需要用的时间。

阅读全文 »

生成数据集

1
2
3
4
5
6
7
8
9
import torch

num_inputs=2 #特征数
num_examples=1000 #样本数
true_w=[2,-3.4] #真实权重
true_b=4.2 #真实偏差
features=torch.randn(num_examples,num_inputs,dtype=torch.float32) #生成特征
labels=true_w[0]*features[:,0]+true_w[1]*features[:,1]+true_b #生成标签 [:,0]表示取所有行的第0个元素
labels+=torch.tensor(torch.normal(0,0.01,size=labels.size()),dtype=torch.float32) #加入噪声
阅读全文 »

线性回归输出的是连续值,适用于如预测房屋价格、气温、销售额等连续值的问题。

线性回归的基本要素

模型定义

阅读全文 »
0%