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

相关推荐
AI周红伟7 分钟前
周红伟:《OpenClaw安全防控:OpenClaw++Skills智能体安全部署、实操和企业应用实操》
人工智能·阿里云·云计算·腾讯云·openclaw
火山引擎开发者社区15 分钟前
ArkClaw 适配微信,可以在微信上指挥你的龙虾啦
人工智能
小超同学你好41 分钟前
Langgraph 18. Skill 四种形态 —— Inline / File-based / External / Meta(含代码示例)
人工智能·语言模型·langchain
不只会拍照的程序猿41 分钟前
《嵌入式AI筑基笔记02:Python数据类型01,从C的“硬核”到Python的“包容”》
人工智能·笔记·python
uzong42 分钟前
Skill 被广泛应用,到底什么是 Skill,今天详细介绍一下
人工智能·后端·面试
Jokeny1 小时前
OpenClaw本地"养虾"全攻略:数据真·不出电脑,本地大模型+飞书自动化方案
人工智能
reesn1 小时前
copaw梳理
人工智能
算法玩不起1 小时前
以乳腺癌诊断数据为例的医学AI分类建模方法入门
人工智能·分类·数据挖掘
Tadas-Gao1 小时前
Mem0分层记忆系统:大语言模型长期记忆的架构革命与实现范式
人工智能·语言模型·自然语言处理·架构·大模型·llm·transformer
极客小俊1 小时前
Windows 卸载 OpenClaw
人工智能