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

相关推荐
xsd20241118几秒前
Pdf-Inspector开源工具:用Rust实现毫秒级PDF分类、文本提取与Markdown转换
人工智能
Yanjun2i1 分钟前
Agent学习记录五:Pydantic验证
人工智能·python·学习
找方案3 分钟前
AI视频生成对决:Sora vs 可灵 vs Veo,谁能定义未来
人工智能·机器学习·音视频
AI_Auto23 分钟前
架构视角看数字化转型|核心架构:大共享平台+小应用,从按需走向适变
大数据·人工智能·架构·制造
小蒋观天下31 分钟前
社区AI智能摄像头完整选型指南
大数据·人工智能·安全·计算机视觉·语音识别·ai大模型
xsd2024111838 分钟前
雷达点云与海康摄像机数据融合全解析:从标定同步到工程实践的技术指南
人工智能
冬奇Lab39 分钟前
DeepSeek Harness 系列(03):工具系统——给 Agent 装上手
人工智能·deepseek
AI 思录40 分钟前
Prompt 事故档案(八):日常表达被标为“待校准”,AI 的爹味语法从哪里来
大数据·人工智能·算法·prompt·用户体验·ai合规
冬奇Lab43 分钟前
一天一个开源项目(第214篇):AstronRPA —— 科大讯飞开源的企业级 RPA + AI Agent 自动化平台
人工智能·开源·资讯
月光船幽幽1 小时前
跨范式映射的稳定接口设计
人工智能·python·算法