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

相关推荐
IT研究室6 分钟前
最新大数据毕业设计选题推荐-基于大数据的人工智能社交媒体情绪分析与可视化的设计与实现-大数据-Spark-Hadoop-Bigdata
大数据·人工智能·课程设计
Figo_Cheung13 分钟前
Figo生成式人工智能潜空间计算最优参数规模研究
人工智能·空间计算
这张生成的图像能检测吗13 分钟前
(论文速读)一种用于图像超分辨率的有效扩散变换结构
人工智能·计算机视觉·扩散模型·超分辨率
Eric.4614 分钟前
ComfyUI 本地部署 AI 漫剧与 AI 视频流水线:消费级显卡显存优化、角色一致性工程实战
人工智能·自动化·音视频·comfyui·ai漫剧
白猫不黑16 分钟前
AI自动化漏洞挖掘从入门到进阶超详细学习路线
人工智能·学习·web安全·网络安全·信息安全·渗透测试·自动化
百度Geek说23 分钟前
Agentic Harness Workflow 框架:把 AI Coding 变成工程化流程
人工智能
Data-Miner25 分钟前
离线AI制表:模型适配与脚本固化实操
大数据·数据库·人工智能·excel
指针向南28 分钟前
视频截图发黑先检查透明区域
图像处理·人工智能·计算机视觉·音视频
地平线开发者33 分钟前
MQBench QAT量化实践指南
人工智能·算法·自动驾驶
Είναι η κοπέλα42 分钟前
llama.cpp 与 GGUF 格式:本地大模型的“裸引擎“
开发语言·人工智能·pytorch·python·conda