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

Creating data for our neural network

The get_data function in our first neural network code creates two variables, x and y, of sizes (17, 1) and (17). We will take a look at what happens inside the function:

def get_data():
train_X = np.asarray([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167,
7.042,10.791,5.313,7.997,5.654,9.27,3.1])
train_Y = np.asarray([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221,
2.827,3.465,1.65,2.904,2.42,2.94,1.3])
dtype = torch.FloatTensor
X = Variable(torch.from_numpy(train_X).type(dtype),requires_grad=False).view(17,1)
y = Variable(torch.from_numpy(train_Y).type(dtype),requires_grad=False)
return X,y

主站蜘蛛池模板: 扎兰屯市| 盘锦市| 津市市| 博乐市| 越西县| 福建省| 东城区| 临湘市| 青河县| 咸阳市| 吴桥县| 襄樊市| 偏关县| 祁阳县| 青海省| 太原市| 延长县| 伊吾县| 阳城县| 五常市| 大冶市| 黔西| 金溪县| 东兰县| 元谋县| 云龙县| 资兴市| 望江县| 临城县| 承德市| 沁水县| 凯里市| 天等县| 定南县| 顺义区| 疏勒县| 诏安县| 潞城市| 栾川县| 吉木萨尔县| 德清县|