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

相关推荐
2603_966302751 小时前
2026企业AI办公工具选型全指南
人工智能
Henry-SAP1 小时前
AI芯片与具身智能双突破
人工智能·云原生·sap·erp
Leo.yuan1 小时前
Kafka数据实时入仓的两种路径:Kafka Connect vs FineDataLink
大数据·人工智能
海盗12341 小时前
微软技术日报·2026-08-28——微软正式将 Microsoft 365 Roadmap 重命名为 **AI at Work
人工智能·microsoft
玹外之音1 小时前
Codex CLI 非交互模式:把 AI 接入你的 CI/CD 流水线
人工智能·ci/cd·交互
u1301301 小时前
AI 日报(2026年8月28日)
人工智能
向上的车轮1 小时前
DeepSeek Harness:用 Creator 模式开发自定义插件,从 0 到可调用
人工智能·deepseekharness
老郑聊AI业财智造1 小时前
从“思考-行动”到“知行合一”:ReActAgent的架构原理与工程实践全景剖析
人工智能·架构·系统架构·软件工程·软件构建
l1258651 小时前
# LangGraph Tool Calling Agent 深度实战:从零构建 ReAct 循环与工具调用链
人工智能·python·自然语言处理·langchain·agent
VIP_CQCRE1 小时前
用 Ace Data Cloud 快速接入 MiniMax H3:从提示词到 2K 商业级视频生成
人工智能·api·ai视频·minimax·ace data cloud