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 分钟前
【进阶篇】告别 Skill 互相打架|从单技能搭建 Skill 系统
人工智能·ai·prompt
oil欧哟1 分钟前
GPT Image 生图与修图提示词指南
人工智能
雾隐隐o4 分钟前
AI 零代码生成平台 06|对话历史、游标分页与 Redis 记忆
数据库·人工智能·redis
羲云网络10 分钟前
GPT Image 2.6 标注引导编辑:透明 PNG、markup 请求与局部验收
图像处理·人工智能·python·api
雾喔11 分钟前
从猫的一个决定,理解机器学习在学什么
人工智能·机器学习
JAVA面经实录91716 分钟前
AI 辅助写单元测试
java·人工智能·单元测试·ai编程
科创致远20 分钟前
熟练工难留、新人上手慢,AI智能工位怎样沉淀工艺经验?
大数据·服务器·人工智能·制造·精益工程
Hotchip_MEMS23 分钟前
MEMS麦克风、ANC、ENC如何协同提升音频体验?
人工智能·笔记·物联网·电脑·制造
AI创界者26 分钟前
Python 进阶实战(第八十五章):基于 Redis Lua 原子租约的分布式锁、看门狗续期与本地事务表/Outbox 一致性实战
人工智能·python·aigc
愚公搬代码36 分钟前
【愚公系列】《微信小程序项目实战(AI编程+视频图解)》045-项目实战:使用 AI 编程工具辅助实现我的订单页面
人工智能·微信小程序·ai编程