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

相关推荐
罗西的思考7 分钟前
【OpenClaw具身硬件】MiniClaw 阅读笔记---(1)基础
人工智能·算法·机器学习
DevUI团队16 分钟前
从“即兴创作”到“规格先行”,华为云码道(CodeArts)代码智能体持续深耕企业级规范驱动开发能力
前端·人工智能·后端
论文避坑指南19 分钟前
论文写作全流程AI合规边界:从选题到投稿的“红绿灯“清单
大数据·人工智能·深度学习
Dawson Zhu35 分钟前
工业世界模型——基于AI Agent+数学仿真架构
人工智能·架构·agi
冬奇Lab36 分钟前
开源项目第183期:Ontology Playground — 微软出品的本体论可视化学习工具,零后端、浏览器直接运行
人工智能·microsoft·开源
Wang's Blog39 分钟前
AI Agent白手起家52: 从零搭建钉钉智能助手——资源准备与核心架构实现
人工智能·架构·钉钉
冬奇Lab43 分钟前
代码库知识库系列(13):评测——怎么知道知识库够不够好
人工智能
字节跳动视频云技术团队1 小时前
把 AI 视频的钱花在刀刃上,不是每一刀上
人工智能·音视频开发
蛋先生DX1 小时前
大模型参数存储格式揭秘:BF不是男朋友
深度学习·算法·llm
jufeng13071 小时前
【系列:手搓自主 AI Agent:Hermes 架构原理剖析 · 第 1 篇】
人工智能·python·架构·agent