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

相关推荐
lczdyx1 天前
【胶囊网络 - 简明教程】02-1 胶囊网络 - 整体架构设计
人工智能·深度学习·机器学习·ai·大模型·反向传播·胶囊网络
小雨中_1 天前
2.6 时序差分方法(Temporal Difference, TD)
人工智能·python·深度学习·机器学习·自然语言处理
落羽的落羽1 天前
【Linux系统】磁盘ext文件系统与软硬链接
linux·运维·服务器·数据库·c++·人工智能·机器学习
民乐团扒谱机1 天前
【硬科普】位置与动量为什么是傅里叶变换对?从正则对易关系到时空弯曲,一次讲透
人工智能·线性代数·正则·量子力学·傅里叶变换·对易算符
七夜zippoe1 天前
图神经网络实战:从社交网络到推荐系统的工业级应用
网络·人工智能·pytorch·python·神经网络·cora
啊阿狸不会拉杆1 天前
《计算机视觉:模型、学习和推理》第 1 章 - 绪论
人工智能·python·学习·算法·机器学习·计算机视觉·模型
X54先生(人文科技)1 天前
叙事响应:《当预言泛起涟漪——碳硅智能时代的叙事开篇》
人工智能·ai编程·ai写作
硅谷秋水1 天前
具身智能中的生成多智体协作:系统性综述
人工智能·深度学习·机器学习·语言模型·机器人
爱吃羊的老虎1 天前
【大模型应用】MCP (Model Context Protocol):AI界的USB接口
人工智能
用户5191495848451 天前
curl中的TFTP实现:整数下溢导致堆内存越界读取漏洞
人工智能·aigc