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

相关推荐
用户4330514143818 分钟前
流程控制与并行工作
人工智能
云天AI实战派9 分钟前
ChatGPT/API 调用故障排查指南:Realtime 音频、智能体浏览器操作与 AI 编码代理全流程修复手册
人工智能·chatgpt·音视频
水上冰石12 分钟前
怎么查看olama是否用到了显卡加速
人工智能·显卡
码点滴16 分钟前
用自然语言指挥 K8s 集群:AI 运维 Agent 的架构原理与可运行原型
运维·人工智能·kubernetes
Wanderer X18 分钟前
【LLM】PPO
人工智能
霍夫曼vx_helloworld735218 分钟前
字符提取与字符识别
图像处理·人工智能·计算机视觉
小许同学记录成长19 分钟前
基于幅度形态与参数聚类的工作模式判别
python·算法·scikit-learn
Wang60720 分钟前
浅尝claude code记忆系统
人工智能
郑寿昌25 分钟前
AI时代动画游戏教育新变革
人工智能·游戏
LLWZAI26 分钟前
不用大改原文,也能安稳通过朱雀 AI
人工智能