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

相关推荐
阿部多瑞 ABU6 小时前
#联动悖论
人工智能·ai写作
EmmaXLZHONG6 小时前
Deep Learning With Pytorch Notes
人工智能·pytorch·深度学习
格鸰爱童话6 小时前
向AI学习项目技能(六)
java·人工智能·spring boot·python·学习
V搜xhliang02466 小时前
影像医学与人工智能融合的教学体系构建及平台应用研究
人工智能
Master_oid7 小时前
机器学习38:距离度量与特征处理
人工智能·机器学习
天地炫舞7 小时前
记录一个使用AI开发企业官网的思路
人工智能
阿星AI工作室7 小时前
我用Gemini手搓了高颜MBTI人格测试网站!附全套提示词
人工智能·html
龙文浩_7 小时前
AI NLP核心技术指南
人工智能·pytorch·深度学习·神经网络·自然语言处理
血小溅7 小时前
大脑与双手的分离:Claude Code vs Managed Agents 深度对比指南
人工智能
星爷AG I7 小时前
19-4 模糊语言学(AGI基础理论)
人工智能·agi