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

相关推荐
武天旭18 分钟前
AI安全--AI大模型的数据投毒攻击解析
人工智能·深度学习·安全
AI技术新视界18 分钟前
LLM 提示词缓存(Prompt Caching)的秘密
人工智能·缓存·llm·prompt
todoitbo24 分钟前
我在 Mac 上用 Docker 部署 Nexent:从拉取镜像到接入模型
macos·docker·大模型·ai智能体·nexent·快速入门与环境准备
火山引擎开发者社区30 分钟前
从企业开发者到 Agent 先锋,火山引擎 Agent 先锋计划邀你进击!
人工智能
这张生成的图像能检测吗43 分钟前
(论文速读)Ponder:通过神经渲染进行点云预训练
人工智能·深度学习·机器学习·点云·3d技术·神经渲染
johnsong1 小时前
AI前沿日报 · 2026-11-05:暗网与裂痕
人工智能
张彦峰ZYF1 小时前
升级了不等于变好了:AI回归测试的固定评测集、版本对比、质量阈值与CI门禁
人工智能·后端·模型或提示词升级·语言模型没有编译器与确定性输出·总体、切片与回退清单·红线、护栏与目标·ci门禁把判定写进合并路径
迪康coolmu1 小时前
企业U盘管控落地实战:基于迪康端点安全一体化管理系统的移动存储安全实践
运维·人工智能·经验分享·笔记·安全·电脑
GitCode官方1 小时前
活动预告 | 模力无限 × AtomGit珠海首场 AI Meetup,来了
人工智能·atomgit
QXWZ_IA1 小时前
电离层扰动影响RTK精度的机理与工程应对方法
人工智能