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

相关推荐
xiezhr几秒前
折腾了一下午,终于让Codex用上了DeepSeek
人工智能·openai·deepseek
lauo1 分钟前
ibbot角色智能体 v2.0 升级公告:全新上下文限制功能上线————灵活适配速度与深度,让每位数字伙伴更懂你
人工智能·智能手机·电脑·娱乐
我爱cope3 分钟前
【Agent智能体22 | 构建AI工作流的技巧-延迟、成本优化】
人工智能·设计模式·语言模型·职场和发展
basketball6164 分钟前
AI Infra 硬件体系与编程模型:3. GPU 流处理器解析
人工智能
装不满的克莱因瓶5 分钟前
了解不同机器学习模型的分类
人工智能·python·算法·机器学习·ai·分类·数据挖掘
我爱吃土豆15 分钟前
Agent 的记忆机制
开发语言·数据库·人工智能
Yuk丶8 分钟前
厌倦了假AI对话?本地 LLM 语音对话 + 口型同步系统 2.0(已开源!)
c++·人工智能·语言模型·开源·ue4·语音识别·游戏开发
AI周红伟12 分钟前
事件分析:FDE标准,“OpenClaw+RAG+Agent” 应用实战的标准
前端·人工智能·chrome·chatgpt·aigc
嵌入式-老费16 分钟前
esp32开发与应用(ps2摇杆的开发)
人工智能
通信大模型18 分钟前
IEEE JSAC | 4万字综述 | 从Large AI Models到Agentic AI:面向未来智能通信的教程
人工智能·深度学习·神经网络·信息与通信