Deep Learning(3)

Linear Units in Keras

The easiest way to create a model in Keras is through 'keras.Sequential', which creates a stack of layers from a neural network. Of course, we can also use a dense layer to create the model.

We can define a linear model that takes three input features ('sugars', 'fiber', and 'protein') and then generate a simgle output ('calories') like this:

python 复制代码
from tensorflow import keras
from tensorflow.keras import layers

# Create a network with 1 linear unit
model = keras.Sequential([
    layers.Dense(units=1, input_shape=[3])
])

With the first parameter, 'units' , we define how many outputs we want. In this case, we're just predicting 'calories', so we'll use 'units = 1'.

With the second parameter, 'input_shape', we tell Keras the dimension of the inputs. Setting 'input_shape=3' ensures that the model will accept three features as input ('sugars', 'fiber', and 'protein').

This model is now ready to be fit to training data

相关推荐
严肃小白兔6 小时前
第 17/24 期:卷积神经网络的数学原理与计算过程
人工智能·神经网络·cnn
LabVIEW开发6 小时前
Sherborne 倾角仪 + LabVIEW 倾角怎么测?
人工智能·labview
stormzhangV6 小时前
一文说清楚 Neon 到底有多强?
人工智能·google·aigc
孟健7 小时前
拆解降噪站 Noise Reducer:定价页这样设计,月访问 49 万
人工智能·aigc
英辰朗迪AI获客7 小时前
英辰朗迪AI获客每日AI精选(2026.11.21)
人工智能
RSABLOCKCHAIN7 小时前
【AI应用】Agent三种实现范式的对比
人工智能
八月瓜科技7 小时前
专精特新企业如何搭建专利资产中台?三步落地法
大数据·数据库·人工智能·科技·深度学习·机器学习·oracle
码农飞哥9 小时前
WorkBuddy 六步,把每天点的几十下做成扩展
人工智能·效率·ai工具·workbuddy
aimartec9 小时前
跨城定制软件与APP开发技术选型与源码验收规范(中小企业实用版)
人工智能