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

相关推荐
糖葫芦君20 小时前
RQ-VAE(残差量化-变分自编码器)
人工智能·深度学习
skywalk816321 小时前
Warp为 21 世纪打造的智能终端
人工智能
JAVA+C语言21 小时前
3ds Max 2025 最新版本3D软件下载安装激活步骤
人工智能
hkNaruto21 小时前
【AI】AI学习笔记:A2A(智能体协作)入门指南:从概念到实践
人工智能·笔记·学习
石云升21 小时前
我在企业落地AI这一年,全流程案例拆解,企业落地AI必看!
人工智能·ai编程
yj_sharing21 小时前
动手学深度学习softmax回归的笔记
笔记·深度学习·回归
MM_MS21 小时前
Halcon基础知识点及其算子用法
开发语言·人工智能·python·算法·计算机视觉·视觉检测
温柔只给梦中人21 小时前
深度学习:day03-04
人工智能·深度学习
棒棒的皮皮21 小时前
【深度学习】YOLO 模型部署全攻略(本地 / 嵌入式 / 移动端)
人工智能·深度学习·yolo·计算机视觉
a程序小傲21 小时前
小红书Java面试被问:TCC事务的悬挂、空回滚问题解决方案
java·开发语言·人工智能·后端·python·面试·职场和发展