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

相关推荐
deephub13 小时前
Agent = Model + Harness:模型决定上限Harness 决定下限
人工智能·大语言模型·agent·harness
GalenZhang88813 小时前
Hermes Agent v0.14.0:AI Agent 基建时代正式到来
人工智能·hermes
动物园猫13 小时前
金属外表多种生锈检测数据集分享(适用于YOLO系列深度学习分类检测任务)
深度学习·yolo·分类
俊哥V13 小时前
每日 AI 研究简报 · 2026-05-17
人工智能·ai
johnrui14 小时前
RAG系统“入口”和“出口”的进化
人工智能
cyyt14 小时前
深度学习周报(5.11~5.17)
人工智能·深度学习
搬砖的小码农_Sky14 小时前
如何在RX 7900 XTX显卡上运行ROCm?
深度学习·机器学习·gpu算力
鹏子训14 小时前
MemoryOS:开源时序知识图谱AI记忆系统
人工智能·知识图谱·记忆模块·ai记忆·memoryos·时序记忆
泰迪智能科技14 小时前
高校人工智能与大数据产品体系及解决方案介绍
大数据·人工智能