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

相关推荐
智联视频超融合平台32 分钟前
消防宣传月过半,“AI+消防“给视频平台换了张考卷
人工智能·边缘计算·视频监控·安防·视频联网
冬奇Lab1 小时前
一天一个开源项目(第262篇):AG-UI —— 把 AI Agent 接进前端的开放协议,和 MCP、A2A 并列的第三块拼图
人工智能·开源
罗西的思考2 小时前
【轻量化复现大模型 / KIMI K3】MTP / EAGLE‑3 模块交互式演示
人工智能·深度学习·算法
RobinDevNotes3 小时前
Claude Code 剪视频,不上传、不要 API Key
人工智能·python·音视频·开发工具·ipython
stormzhangV3 小时前
Coding Agent,通往 AGI 的重要一环
人工智能·agent·ai编程
Bowen_J4 小时前
Apple Foundation Models:Apple AI核心框架
人工智能·ai编程·apple
IT_陈寒4 小时前
Redis那个过期删除策略,差点让我线上崩了
前端·人工智能·后端
阿里云大数据AI技术5 小时前
AI 原生大数据服务 ADA 快速入门:完成首次对话式数据分析
大数据·人工智能
字节跳动开源5 小时前
小红书/抖音图文排版利器——一个杂志风skill
人工智能·开源·设计
Bacon5 小时前
我把 Codex 塞进了 Touch Bar:一个 30pt 高的额度与对话面板
人工智能