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

相关推荐
踏浪无痕28 分钟前
架构师如何学习 AI:三个月掌握核心能力的务实路径
人工智能·后端·程序员
闲看云起37 分钟前
大模型应用开发框架全景图
人工智能·语言模型·ai编程
CoovallyAIHub41 分钟前
工业视觉检测:多模态大模型的诱惑
深度学习·算法·计算机视觉
万行1 小时前
机器学习&第三章
人工智能·python·机器学习·数学建模·概率论
木卫四科技1 小时前
DocETL 入门:让非结构化数据处理变得简单智能
人工智能·木卫四
玖日大大1 小时前
OceanBase SeekDB:AI 原生数据库的技术革命与实践指南
数据库·人工智能·oceanbase
小润nature1 小时前
Spec-Driven Development (SDD) 框架与开源 AI 智能体-意图的进化
人工智能·开源
后端小肥肠1 小时前
复刻10W+爆款视频!我用Coze搭了个“人物故事”自动流水线,太香了!
人工智能·aigc·coze
轻竹办公PPT1 小时前
2026 年工作计划 PPT 内容拆解,对比不同 AI 生成思路
人工智能·python·powerpoint
浔川python社1 小时前
【版本更新提示】浔川 AI 翻译 v6.0 合规优化版已上线
人工智能