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

相关推荐
PM老周3 分钟前
PRD怎么用AI质检?需求预审、人工复核与整改闭环
人工智能·项目管理·产品经理·prd
lialaka13 分钟前
「声纹迷宫(Acoustic Labyrinth)」:具身交互智能驱动的实时声学解构与全双工语音数字人控制台
人工智能·3d·交互
BerryS3N18 分钟前
Java 后端转型大模型:Demo 能跑不等于能上线
java·人工智能·python·java后端·spring ai·langchain4j·大模型转型
制造数据与AI践行者老蒋23 分钟前
智联工坊实战:从“金鱼记忆”到“记住了”:给制造Agent装上记忆芯片的完整指南
人工智能·python·langchain·制造
硬核子牙34 分钟前
大模型是怎么学会的
人工智能·chatgpt·计算机组成原理
D11_38 分钟前
如何选择靠谱的 GEO 品牌服务商
大数据·人工智能
无忧智库43 分钟前
某集团数字人客服多模态交互与情感语音合成平台详细设计方案(WORD)
人工智能
罗西的思考1 小时前
【Agentic RL / 强化学习 / OPD】OpenClaw-RL 源码阅读笔记 — (14)— Teacher
人工智能·笔记·深度学习·算法·机器学习
薛定e的猫咪1 小时前
如何高效构建一个RAG知识库 dify实例与常见问题
人工智能·深度学习
塔能物联运维1 小时前
**塔能两相液冷:量化交易场景下的硬核验证,±1.5℃控温如何转化为真金白银**
人工智能·fpga开发·两相液冷