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

相关推荐
辉视广播对讲1 小时前
医院IPTV,让医疗服务更有温度
网络·人工智能
xqqxqxxq2 小时前
Java AI智能P图工具技术笔记
java·人工智能·笔记
AI袋鼠帝2 小时前
本地4B开源模型,把任何App当Skil用!告 别token焦虑,私密性强~
人工智能
ComputerInBook2 小时前
数字图像处理(4版)——第 11 章——特征提取(下)(Rafael C.Gonzalez&Richard E. Woods)
图像处理·人工智能·特征提取
在线打码2 小时前
ToutiaoAI:AI 驱动的智能新闻杂志平台
人工智能·ai·aigc·ai写作·新闻资讯
ar01232 小时前
AR电路巡检:让电力运维进入智能可视化时代
运维·人工智能·ar
低调小一2 小时前
Midscene.js 原理拆解:它不是“自然语言点按钮”,而是一套会看屏幕的 UI 自动化运行时
人工智能·rnn·架构·大模型·transformer·tdd·midscene
Slow菜鸟2 小时前
Codex CLI 教程(五)| Skills 安装指南:面向 Java 全栈工程师打造个人 ECC(V1版)
大数据·前端·人工智能
昇腾CANN2 小时前
5月11日直播丨CANN算子挑战赛(江山赛区)赛题和评分规则解读
人工智能·昇腾·cann·deepseek
菜鸡信息技术2 小时前
VSCode 安装 Claude Code 插件,配置 DeepSeek V4(Windows)
人工智能