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

相关推荐
晓翔仔1 小时前
【深度实战】Agentic AI 安全攻防指南:基于 CSA 红队测试手册的 12 类风险完整解析
人工智能·安全·ai·ai安全
百家方案1 小时前
2026年数据治理整体解决方案 - 全1066页下载
大数据·人工智能·数据治理
北京耐用通信2 小时前
工业自动化中耐达讯自动化Profibus光纤链路模块连接RFID读写器的应用
人工智能·科技·物联网·自动化·信息与通信
小韩博3 小时前
一篇文章讲清AI核心概念之(LLM、Agent、MCP、Skills) -- 从解决问题的角度来说明
人工智能
沃达德软件4 小时前
人工智能治安管控系统
图像处理·人工智能·深度学习·目标检测·计算机视觉·目标跟踪·视觉检测
高工智能汽车4 小时前
爱芯元智通过港交所聆讯,智能汽车芯片市场格局加速重构
人工智能·重构·汽车
大力财经4 小时前
悬架、底盘、制动被同时重构,星空计划想把“驾驶”变成一种系统能力
人工智能
梁下轻语的秋缘5 小时前
Prompt工程核心指南:从入门到精通,让AI精准响应你的需求
大数据·人工智能·prompt
FreeBuf_5 小时前
ChatGPT引用马斯克AI生成的Grokipedia是否陷入“内容陷阱“?
人工智能·chatgpt
福客AI智能客服5 小时前
工单智转:电商智能客服与客服AI系统重构售后服务效率
大数据·人工智能