最新文章:

首页 机器学习

Tensorflow-Exercise1

发布时间:2019年04月14日 评论数:抢沙发 阅读数:608

    n this exercise you'll try to build a neural network that predicts the price of a house according to a simple formula. So, imagine if house pricing was as easy as a house costs 50k + 50k per bedroom, so that a 1 bedroom house costs 100k, a 2 bedroom house costs 150k etc. How would you create a neural network that learns this relationship so that it would predict a 7 bedroom house as costing close to 400k etc. Hint: Your network might work better if you scale the house price down. You don't have to give the answer 400...it might be better to create something that predicts the number 4, and then your answer is in the 'hundreds of thousands' etc.

    import tensorflow as tf
    import numpy as np
    from tensorflow import keras
    model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
    model.compile(optimizer='sgd', loss='mean_squared_error')
    xs = np.array([1,  2, 4, 5, 8, 10,6], dtype=float)
    ys = np.array([50,  150, 250, 300, 450, 550,350], dtype=float)
    model.fit(xs, ys, epochs=5000)
    print(model.predict([7.0]))

二维码加载中...
本文作者:HDC      文章标题: Tensorflow-Exercise1
本文地址:http://hdcin.cn/?post=307
版权声明:若无注明,本文皆为“小胖Blog's”原创,转载请保留文章出处。
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论