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

相关推荐
Coovally AI模型快速验证26 分钟前
农田扫描提速37%!基于检测置信度的无人机“智能抽查”路径规划,Coovally一键加速模型落地
深度学习·算法·yolo·计算机视觉·transformer·无人机
媒体人8881 小时前
GEO 优化专家孟庆涛:技术破壁者重构 AI 时代搜索逻辑
大数据·人工智能
小菜AI科技1 小时前
Windsurf 评测:这款 人工智能 IDE 是你需要的颠覆性工具吗?
人工智能
RaymondZhao341 小时前
【全面推导】策略梯度算法:公式、偏差方差与进化
人工智能·深度学习·算法·机器学习·chatgpt
yzx9910132 小时前
小程序开发APP
开发语言·人工智能·python·yolo
AKAMAI2 小时前
通过自动化本地计算磁盘与块存储卷加密保护数据安全
人工智能·云计算
无规则ai2 小时前
动手学深度学习(pytorch版):第四章节—多层感知机(5)权重衰减
人工智能·pytorch·python·深度学习
zskj_zhyl3 小时前
家庭健康能量站:微高压氧舱结合艾灸机器人,智享双重养生SPA
人工智能·科技·安全·机器人
朗迪锋3 小时前
数字孪生 :提高制造生产力的智能方法
大数据·人工智能·制造
网安INF3 小时前
【论文阅读】-《HopSkipJumpAttack: A Query-Efficient Decision-Based Attack》
论文阅读·人工智能·深度学习·网络安全·对抗攻击