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

相关推荐
TYUT_xiaoming1 分钟前
yolo模型训练
人工智能·python·yolo
2301_780789666 分钟前
零信任架构中,身份感知防火墙(IAFW)的部署要点与最佳实践
linux·运维·服务器·人工智能·tcp/ip·架构
MicroTech20257 分钟前
业绩披露|微算法科技(MLGO)2025年净利润1.27亿元
大数据·人工智能·科技
百度Geek说8 分钟前
Superpowers:给 Claude Code 装上“工程大脑”
人工智能
AGIPlayer8 分钟前
没有生态的大模型不算前沿
大数据·人工智能·物联网
lulu121654407813 分钟前
OpenRouter Fusion 多模型融合架构深度拆解:预算级模型组团打平 Fable 5,多模型协作才是 AGI 的正确打开方式?
java·人工智能·架构·ai编程·agi
恋猫de小郭18 分钟前
Redis 作者反驳「中国模型之所以强,是因为通过 API 蒸馏了美国模型」
前端·人工智能·ai编程
林间码客29 分钟前
04 ROC曲线与AUC:从零开始手动计算
大数据·人工智能·算法
codexu32 分钟前
NoteGen 里一条记录如何变成 Markdown
人工智能
澄旭40 分钟前
拆解一个成熟 Skill,看懂 Skill 到底该怎么写
人工智能