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

相关推荐
阡陌数智4 分钟前
Gemini 4 Argon 百万 Token 输出能力解析:原生长输出模型的工程落地与并发成本治理
人工智能·架构
丑梨数据9 分钟前
信创环境里跑文档工具:格式兼容与本地合规的几个坑
数据结构·人工智能·算法·决策树·排序算法
麦豆GEO21 分钟前
GEO与传统内容营销的核心差异:AI时代内容运营的全面升级
大数据·人工智能·内容运营
禁默30 分钟前
Embodied VideoAgent 论文解读:机器人怎样持续记住动态场景
人工智能·机器人
Rocky Ding*38 分钟前
FLUX 3 Image Klein 技术解析:5.6B 生成器、Flow Map 蒸馏与 ComfyUI 可控编辑
论文阅读·人工智能·深度学习·机器学习·aigc·flux·ai-native
围炉聊科技1 小时前
MCP 里的 SSRF:为什么“让 Agent 取什么就取什么”如此危险——智能体基建系列
人工智能
无障碍研究院1 小时前
2026TADC|李庆阳:探讨科技无障碍实践与行动经验
人工智能
workflower1 小时前
Agentic AI 时代的企业ICT 基础设施运维
运维·人工智能·机器学习·重构·云计算·汽车
szxinmai主板定制专家1 小时前
ZYNQ 数据采集方案踩坑总结:电力强电磁干扰、工业现场多协议适配优化
运维·人工智能·fpga开发·机器人·zynq
goujunwe2 小时前
短视频怎么做 GEO:优化字幕和文稿,提升 AI 文本抓取采信率
大数据·人工智能·音视频