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

相关推荐
小二·5 分钟前
2026 年 AI 编程工具终极横评:Cursor vs Claude Code vs Copilot vs Windsurf
人工智能·copilot
lucky_syq5 分钟前
【深度学习核心】注意力机制(Attention)详细解析
人工智能·深度学习
Deepoch5 分钟前
Deepoc VLA开发板:除草机器人田间自主智能闭环解析
人工智能·具身模型·deepoc·除草机器人
weixin_550083157 分钟前
基于知识图谱的python个性化学习路径推荐系统项目源码
人工智能·学习·知识图谱
weixin_3975740911 分钟前
AI Agent黑盒怎么破?一次推理可视化实践深度复盘
人工智能
chian-ocean13 分钟前
多模态的端到端跃迁:SenseNova U1 原生图文交错生成能力与技术应用全景解析
人工智能
moonsims13 分钟前
基于端(AIBrainBOX)-边(AGH)-云(AI Mission Cloud)-人(GCS)的可扩展、可协同、可演进的无人化系统体系架构USA
人工智能·架构
TE-茶叶蛋17 分钟前
GitNexus 完整技术栈分析
人工智能
启道张恒19 分钟前
飞扬软件「建筑自动化·房间定义」重磅升级:重塑设计效率新标杆
大数据·人工智能·ai设计·bim正向设计·国产二三维设计软件·飞扬集成设计系统
自律懒人19 分钟前
当AI智能体学会了操控浏览器:Chrome CDP + 自动化Agent实战
人工智能·chrome·自动化