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

相关推荐
Starry-sky(jing)1 分钟前
Hermes Agent 部署后怎么升级?v0.21.7 Linux 源代码版实测
linux·人工智能·ai agent·版本升级·hermes agent
柯南46687 分钟前
【AI工程师精讲】10:微调方案选型:全参微调、LoRA、QLoRA 到底怎么选
人工智能·ai编程
黄权光8 分钟前
AI智能体项目实战记录(02):初始化 Python 项目
人工智能
小蒋观天下10 分钟前
厂区人员徘徊游荡判别——基于时序轨迹速度的逗留行为分级算法落地
大数据·人工智能·深度学习·算法·机器学习·ai大模型
方方洛10 分钟前
ai-agent教程-07-从零实现一个工程化AI-Agent
人工智能·llm·agent
龙虾电话11 分钟前
写 telephony 网关时,我把「拨不通」查了三天:AT 命令回 OK 不代表通话接通
人工智能
方方洛11 分钟前
ai-agent教程-08-多智能体协作
人工智能·llm·agent
styshoo11 分钟前
[snapshot]2-snapshot部署
人工智能
changshuaihua00112 分钟前
LangChain · LangGraph · LangSmith 全景解析:LLM应用开发完整生态
人工智能·大模型·ai编程
ITOM运维行者12 分钟前
WAN监控怎么做?从链路质量指标到路径级定位的完整方法
数据库·人工智能·机器学习