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

相关推荐
爱吃rabbit的mq几秒前
第28章:MLOps基础:机器学习的DevOps
人工智能·机器学习·devops
7B_coder1 分钟前
模型推理prefill和decode过程
人工智能·机器学习
是小蟹呀^2 分钟前
【论文阅读12】Circle Loss:一统 Softmax 与 Triplet,从“线性”到“圆形”的优化视角
深度学习·分类·circle loss
X54先生(人文科技)9 分钟前
20260212_Meta-CreationPower_Development_Log(启蒙灯塔起源团队开发日志)
人工智能·机器学习·架构·团队开发·零知识证明
ViiTor_AI9 分钟前
视频字幕怎么去除?5 种方法删除硬编码字幕与软字幕(CapCut 实操)
人工智能·计算机视觉·音视频
咚咚王者10 分钟前
人工智能之视觉领域 计算机视觉 第三章 NumPy 与图像矩阵
人工智能·计算机视觉·numpy
天天进步201510 分钟前
赋予 AI “手”的能力:使用 OpenClaw 自动化执行 Shell 脚本与浏览器任务
人工智能
百度智能云技术站11 分钟前
百度百舸 Day0 完成昆仑芯和智谱 GLM-5 适配,实现「发布即可用」
人工智能·开源·vllm·百度百舸
曦云沐12 分钟前
第六篇:LangChain 1.0 消息系统与 Prompt 工程:从入门到精通的完整教程
人工智能·langchain·prompt·大模型开发框架
格林威12 分钟前
Baumer相机玻璃纤维布经纬密度测量:用于复合材料工艺控制的 6 个核心方法,附 OpenCV+Halcon 实战代码!
人工智能·opencv·计算机视觉·视觉检测·工业相机·智能相机·堡盟相机