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

相关推荐
生成论实验室几秒前
用事件关系网络重新理解AI(二):损失函数、优化器与深度学习的动力学
数据结构·人工智能·深度学习·算法·语言模型
韦胖漫谈IT4 分钟前
提示词注入- 大语言模型 OWASP TOP 10系列
网络·人工智能·语言模型·大模型安全·owasp
HIT_Weston11 分钟前
93、【Agent】【OpenCode】edit 工具提示词(二)
人工智能·agent·opencode
xingyuzhisuan14 分钟前
2026年GPU租用平台JupyterHub多用户环境配置
服务器·人工智能·jupyter·gpu算力
开开心心loky16 分钟前
[OC 底层] (三) 方法缓存与消息发送机制
macos·ios·缓存·objective-c·cocoa
生成论实验室19 分钟前
事件、信息荷与六维态势空间——每一个事件都是一次空间的弯曲
人工智能·算法·语言模型·可信计算技术·安全架构
徐安安ye22 分钟前
FlashAttention长程依赖建模:局部+全局的Hybrid Spiral结构设计
python·深度学习·机器学习
Zevalin爱灰灰30 分钟前
智能控制 第五章——神经网络控制论
人工智能·神经网络
韦胖漫谈IT31 分钟前
供应链 - 大语言模型 OWASP TOP 10系列
人工智能·语言模型·自然语言处理
KaMeidebaby35 分钟前
卡梅德生物技术快报|真核蛋白表达信号肽筛选实验全流程复盘
服务器·前端·数据库·人工智能·算法