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

相关推荐
Rocky Ding*41 分钟前
Muse技术深度解析:用掩码并行生成图像,速度、语义与编辑能力如何同时成立
论文阅读·人工智能·深度学习·机器学习·aigc·ai-native·muse
HIT_Weston1 小时前
15、【数学】【基础】欧拉公式是怎么来的:从级数、微分方程到旋转
人工智能·模型部署
数智前线2 小时前
AI Coding,正在把存储推向前台
人工智能
论文复现现场6 小时前
AutoDL、算家云与公有云 GPU 怎么选?环境复现、计费与断点恢复对比
pytorch·深度学习·云计算·gpu
唠点键盘之外的7 小时前
15 微调 vs RAG:到底怎么选
人工智能·机器学习·面试·aigc
具身AGI8 小时前
人机协同预训练:三条路线,一条拉开差距
人工智能
东风破_8 小时前
LangSmith:从链路追踪到 RAG 自动化评估
人工智能
东方芷兰8 小时前
Agent 技术摘要 04 —— AI4S、VLM、VLA、VLN、WM、AI Infra
人工智能
catchadmin8 小时前
用 Jev 与 Laravel AI SDK 检测垃圾邮件和自动回复
数据库·人工智能·laravel
一 铭8 小时前
Pi实战 05:本地模型 · MCP · 安全沙箱篇
人工智能·ai·agent·harness