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

相关推荐
yyywxk4 分钟前
ICCV 2025 目标检测(object detection)方向上接收论文总结
人工智能·目标检测·计算机视觉
欧特克_Glodon6 分钟前
OpenCV计算机视觉开发入门与实践<十七>:点运算与灰度变换概述
c++·人工智能·opencv·计算机视觉
chen_zn956 分钟前
《VLA 系列》MemoryVLA++ | 感知-认知记忆 | 潜空间未来想象 | 论文与源码边界解析
人工智能·具身智能·vla
狂云歌7 分钟前
AI时代,学什么,怎么学
人工智能·学习
Allen_LVyingbo8 分钟前
医疗AI可扩展网格信息系统中网格计算技术的智能优化
大数据·人工智能·python·算法·机器学习·django·健康医疗
一个帅气昵称啊9 分钟前
.Net C# AI智能体开发-AI智能体
人工智能·c#·.net
MNLoser9 分钟前
AI agent开发——LangGraph接入持久化
linux·人工智能·windows·python
民乐团扒谱机12 分钟前
【读论文】2005 一种旋律转录的分类方法A classification approach to melody transcription[C]
人工智能·分类·数据挖掘
程序员-李俞13 分钟前
Coze 工作流调用异步 HTTP API 完整教程:任务 ID、循环轮询、状态判断与结果 URL 提取
网络·人工智能·网络协议·http·aigc·ai编程·ai写作
柠檬071114 分钟前
图像亮暗不均匀,如何去除背景或者怎么处理可以让图像暗的地方亮一些,亮的地方暗一些
人工智能·opencv·计算机视觉