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

相关推荐
沐泽百川9 小时前
AI 应用上线后怎么排查问题?日志与可观测性应该这样设计
人工智能
在世修行9 小时前
第17篇:晶粒尺寸统计算法 — 从像素到微米的转换
人工智能·计算机视觉·像素转换
万点科技码农9 小时前
2025年7月11日行业热点解读:定制软件开发与AI工作流重构一体化趋势
大数据·人工智能·重构
JL159 小时前
Agent工程-为什么Agent必须有观测和Tracing
服务器·网络·人工智能·安全
用户6954977099499 小时前
第 8 章 vLLM/LMDeploy/Triton 适配 DeepSeek 源码改造
人工智能
波动几何9 小时前
角色生成器character-builder
人工智能
dayuOK63079 小时前
AI Agent市场爆发:从“试一试”到“离不开”,只用了不到一年
大数据·人工智能·ai作画·新媒体运营·aigc·ai写作
茶马古道的搬运工9 小时前
AI 深度技能之-解读Hermes Agent(四)- Hermes Kanban 多 Agent 流水线
人工智能
海外数字观察家9 小时前
马来西亚商贸数字化落地指南:跨境批发、连锁零售首选ERP方案(品未云)
大数据·人工智能·马来西亚进销存系统·马来西亚收银系统·马来西亚erp系统·马来西亚仓库管理系统
珠海西格电力9 小时前
数据采集与治理:零碳园区管理系统的 “生命线”
大数据·人工智能·算法·架构·能源