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

相关推荐
Kainy1 分钟前
把 SSH 权限交给 AI 之前,先给它修一道门,reeve-go 多用户 AI 堡垒机方案深度拆解
运维·人工智能·ssh
罗西的思考1 分钟前
【轻量化复刻大模型 / π0.5】(4)处理输入
人工智能·算法·机器学习
林墨聊AIGC11 分钟前
AI逐帧动画量产秘籍:从零到商业级
大数据·人工智能·科技·ai作画·aigc·音视频
一个天蝎座 白勺 程序猿21 分钟前
AI 学习者的编程技能:Python 高级特性详解(装饰器、生成器、魔法方法实战)
开发语言·人工智能·python·ai编程
一瞬祈望24 分钟前
【CLCD数据】CLCD中国30米逐年土地覆盖数据集详细介绍:1985—2025年数据、分类体系与应用指南
大数据·人工智能·土地利用类型·clcd
代码方舟31 分钟前
零信任架构实战:基于天远车辆过户详版查询构建自动化车源估值核验网关
人工智能·架构·自动化·excel
布吉岛的石头1 小时前
Java 程序员第 52 阶段8:Prompt 约束:限定范围与格式
人工智能·深度学习·transformer
DKPT1 小时前
AI编程助手新利器skills火爆登场
人工智能·笔记·学习·开源·ai编程
米米商聊1 小时前
AI 搜群附件,同一份 PDF 占满前三条?按附件 ID 折叠片段
javascript·人工智能
羲云网络1 小时前
GPT Image 2.6 设备操作说明配图:步骤拆分、结构保留与事实验收
人工智能·图像编辑·技术写作·gpt image 2.6