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

相关推荐
土豆.exe1 天前
IfAI v0.3.0 - 从“文本“到“多模态“的感知升级
人工智能·编辑器
JicasdC123asd1 天前
如何使用YOLOv10n进行台风灾害区域识别与分类——基于改进的HAFB-2模型实现
人工智能·yolo·分类
抖知书1 天前
喂饭级AI提示词公开!帮短视频创作者写脚本大纲
人工智能
Elastic 中国社区官方博客1 天前
JINA AI 与 Elasticsearch 的集成
大数据·人工智能·elasticsearch·搜索引擎·全文检索·jina
高洁011 天前
AI智能体搭建(3)
人工智能·深度学习·算法·数据挖掘·知识图谱
道可云1 天前
道可云人工智能每日资讯|南宁市公布第二批“人工智能+制造”应用场景“机会清单”和“能力清单”
人工智能·制造
ai_top_trends1 天前
不同 AI 生成 2026 年工作计划 PPT 的使用门槛对比
人工智能·python·powerpoint
人工智能AI技术1 天前
开源大模型选型指南:从LLaMA3到文心ERNIE,实战适配不同业务场景
人工智能
TOWE technology1 天前
聚焦价值 重塑增长
大数据·人工智能·企业
老顾聊技术1 天前
“Anthropic 最新发布的 AI Skills:赋能任务自动化与跨领域应用“
运维·人工智能·自动化