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

相关推荐
haoyun6543212 分钟前
一文理清CRM:从基础概念到落地应用完整指南
大数据·人工智能·架构
Nomarsgo3 分钟前
研华PPC-6121工业平板电脑在智能港口岸桥控制终端中的应用方案——打造稳定可靠的港口起重设备人机交互与智能调度平台
人工智能·科技·计算机视觉·视觉检测·电脑·人机交互
骄阳如火17 分钟前
论文撰写SKILLS实测二|academic-research-skills:带“反幻觉内核“的研究→写作→评审全流水线
人工智能
办公室马主任19 分钟前
华南机械加工企业选MES服务商怎么选?
大数据·运维·人工智能·制造
冬奇Lab27 分钟前
代码库知识库系列(10):增量更新——什么时候该重建索引,重建哪些部分
人工智能
技术传感器36 分钟前
Hermes + MCP:搭建真正可落地的 AI 开发工作流
人工智能·架构·aigc·ai编程
碳基猿41 分钟前
新媒体矩阵运营API是什么?企业如何通过API打造自动化内容分发系统?
人工智能·新媒体运营·新媒体矩阵·运营数据统计·矩阵分发
≮傷£≯√1 小时前
opencv 图片合并
人工智能·opencv·计算机视觉
冬奇Lab1 小时前
开源项目第180期:Omnigent — Databricks 出品的 AI Agent 元编排层,让 Claude Code、Codex、Cursor 统一管控
人工智能·开源·agent
kattgatt1 小时前
卡特加特玄武大模型合规备案,商用更安心
人工智能·卡特加特