Update 4.2机器学习(AI)快速入门(quick start).md
This commit is contained in:
@@ -84,19 +84,19 @@
|
||||
|
||||
```python
|
||||
def estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):
|
||||
price = 0<em> # In my area, the average house costs $200 per sqft</em>
|
||||
price = 0 # In my area, the average house costs $200 per sqft
|
||||
price_per_sqft = 200 if neighborhood == "hipsterton":
|
||||
<em> # but some areas cost a bit more</em>
|
||||
# but some areas cost a bit more
|
||||
price_per_sqft = 400 elif neighborhood == "skid row":
|
||||
<em> # and some areas cost less</em>
|
||||
price_per_sqft = 100 <em># start with a base price estimate based on how big the place is</em>
|
||||
price = price_per_sqft * sqft <em># now adjust our estimate based on the number of bedrooms</em>
|
||||
# and some areas cost less
|
||||
price_per_sqft = 100 # start with a base price estimate based on how big the place is
|
||||
price = price_per_sqft * sqft # now adjust our estimate based on the number of bedrooms
|
||||
if num_of_bedrooms == 0:
|
||||
<em># Studio apartments are cheap</em>
|
||||
# Studio apartments are cheap
|
||||
price = price — 20000
|
||||
else:
|
||||
<em> # places with more bedrooms are usually</em>
|
||||
<em> # more valuable</em>
|
||||
# places with more bedrooms are usually
|
||||
# more valuable
|
||||
price = price + (num_of_bedrooms * 1000) return price
|
||||
```
|
||||
|
||||
@@ -212,9 +212,9 @@ def estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):
|
||||
```python
|
||||
def estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):
|
||||
price = 0# a little pinch of this
|
||||
price += num_of_bedrooms * <strong>0.123</strong># and a big pinch of that
|
||||
price += sqft * <strong>0.41</strong># maybe a handful of this
|
||||
price += neighborhood * <strong>0.57</strong>
|
||||
price += num_of_bedrooms * 0.123# and a big pinch of that
|
||||
price += sqft * 0.41# maybe a handful of this
|
||||
price += neighborhood * 0.57
|
||||
return price
|
||||
```
|
||||
|
||||
@@ -328,10 +328,10 @@ print('y_pred=',y_test.data)
|
||||
请注意,我们的神经网络现在有了两个输出(而不仅仅是一个房子的价格)。第一个输出会预测图片是「8」的概率,而第二个则输出不是「8」的概率。概括地说,我们就可以依靠多种不同的输出,利用神经网络把要识别的物品进行分组。
|
||||
|
||||
```python
|
||||
<strong>model = Sequential([Dense(32, input_shape=(784,)), </strong>
|
||||
<strong> Activation('relu'),Dense(10),Activation('softmax')])</strong># 你也可以通过 .add() 方法简单地添加层:<strong> model = Sequential() </strong>
|
||||
<strong> model.add(Dense(32, input_dim=784)) </strong>
|
||||
<strong> model.add(Activation('relu'))# 激活函数,你可以理解为加上这个东西可以让他效果更好</strong>
|
||||
model = Sequential([Dense(32, input_shape=(784,)),
|
||||
Activation('relu'),Dense(10),Activation('softmax')])# 你也可以通过 .add() 方法简单地添加层: model = Sequential()
|
||||
model.add(Dense(32, input_dim=784))
|
||||
model.add(Activation('relu'))# 激活函数,你可以理解为加上这个东西可以让他效果更好
|
||||
```
|
||||
|
||||
虽然我们的神经网络要比上次大得多(这次有 324 个输入,上次只有 3 个!),但是现在的计算机一眨眼的功夫就能够对这几百个节点进行运算。当然,你的手机也可以做到。
|
||||
|
||||
Reference in New Issue
Block a user