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

相关推荐
YMWM_1 小时前
如何将包路径添加到conda环境lerobot的python路径中呢?
人工智能·python·conda
星辰_mya1 小时前
关于ai——纯笔记
人工智能
智算菩萨1 小时前
GPT-5.4原生操控电脑揭秘:从Playwright脚本到屏幕截图识别,手把手搭建你的第一个自动化智能体
人工智能·gpt·ai·chatgpt·自动化
田里的水稻1 小时前
ubuntu22.04_openclaw_ROS2
人工智能·python·机器人
行走__Wz1 小时前
【刘二大人】《PyTorch深度学习实践》——PyTorch实现线性回归代码(自用)
pytorch·深度学习·线性回归
一碗白开水一1 小时前
【工具相关】OpenClaw 配置使用飞书:打造智能飞书助手全流程指南(亲测有效,放心享用)
人工智能·深度学习·算法·飞书
小程故事多_801 小时前
Vibe Coding的致命隐患,你必须知道的技术债务和扩展性危机
大数据·人工智能·aigc
NGBQ121382 小时前
Royal TSX 6.0.2.1000 .dmg 全解析:Mac 端企业级远程连接管理工具深度指南
macos
童话名剑2 小时前
YOLO v3(学习笔记)
人工智能·深度学习·yolo·目标检测
康康的AI博客2 小时前
农业工业变革:如何通过DMXAPI中转提升自动化效率
运维·人工智能·自动化