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

相关推荐
卷福同学6 分钟前
AI编程出海第二步:验证关键词能否做站
前端·人工智能·后端
逻辑君10 分钟前
ANNA 认知引擎 · Humanoid 机器人训练白皮书
人工智能·深度学习·机器学习·机器人
hans汉斯11 分钟前
计算机科学与应用|改进MeanShift算法在智能监控视频中的应用研究
图像处理·人工智能·功能测试·深度学习·算法·音视频
重庆传粉科技18 分钟前
AI推荐生态下品牌内容筛选标准重构与GEO优化路径
人工智能
CIO_Alliance1 小时前
2026年最新iPaaS选型核心关键指标整合
人工智能·ai·ai+ipaas·企业cio联盟·企业级ai化转型
nvvas1 小时前
AI 智能体架构全解:从记忆、工具到多智能体协作的硬核实践
人工智能
veminhe1 小时前
元数据索引有关的错
人工智能·python
一次旅行1 小时前
AutoAWQ完整实战:MIT激活感知AWQ量化,模型显存减半、推理提速且精度无损
人工智能·python·算法
立心者01 小时前
Sdcb Chats .. 发布,彻底移除 Azure.AI.OpenAI 专用包
人工智能·flask·azure
ajassi20001 小时前
AI语音智能体开发日记(五)为智能设备注入“灵魂”——详解MCP工具的注册与使用
人工智能