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

相关推荐
云和数据.ChenGuang7 分钟前
JAVAEE AI工程师路线图
java·人工智能·java-ee·fastapi·springai·langchain4j
Latchh9 分钟前
PDF提取到文字后怎样发现乱码
图像处理·人工智能·计算机视觉·pdf
mit6.82411 分钟前
论拼多多的反向计划经济秩序
人工智能
熊猫钓鱼>_>12 分钟前
从2D平铺到3D沉浸:我用HarmonyOS 7端侧AI做了一个全程数据不出设备的空间化私密相册
前端·人工智能·3d·华为·华为云·harmonyos·鸿蒙
YOLO数据集集合15 分钟前
空中目标检测数据集 | 空中目标检测 无人机识别 鸟类检测 低空安防 反无人机数据集 鸟类 直升机9154期
人工智能·目标检测·计算机视觉·无人机·空中目标·反无人机
Carl_奕然17 分钟前
【智能体】Loop 的四种设计模式之:Event-Driven Loop(2026 最新版)
人工智能·驱动开发·python·设计模式
AI人工智能+19 分钟前
医疗机构执业许可证识别技术融合计算机视觉、OCR与大模型,实现手机拍照或上传文件后自动提取证书关键字段信息
深度学习·自然语言处理·ocr·医疗机构执业许可证识别
Martina_032121 分钟前
AI生成的盔甲换动作后漂移?用6步检查挂点、骨架映射与 Bind Pose
人工智能·游戏·3d·ai·自然语言处理·aigc·游戏策划
Ivanqhz21 分钟前
KV Cache
服务器·数据库·人工智能·深度学习·算法
传奇开心果编程22 分钟前
【Compose Multiplatform 跨端开发学与练】第9课 测试与调试
android·学习·macos·ios·kotlin·web·composer