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

相关推荐
熊崽7 分钟前
Claude Code CLI+英伟达免费api 教程
人工智能
CoovallyAIHub16 分钟前
181小时视频丢给GPT-5,准确率只有15%——南大联合NVIDIA等五校发布多模态终身理解数据集
深度学习·算法·计算机视觉
CoovallyAIHub36 分钟前
CVPR 2026 | GS-CLIP:3D几何先验+双流视觉融合,零样本工业缺陷检测新SOTA,四大3D工业数据集全面领先!
深度学习·算法·计算机视觉
AI攻城狮1 小时前
OpenFang 给我的一个提醒:AI Agent 真正难的不是自主,而是治理
人工智能·云原生·aigc
ZhengEnCi1 小时前
10. 重排序模型实战-BGE-Rerank应用
人工智能
DevUI团队4 小时前
🚀 【Angular】MateChat V20.2.2版本发布,新增8+组件,欢迎体验~
前端·javascript·人工智能
DevUI团队4 小时前
🚀 MateChat V1.11.0 震撼发布!新增工具按钮栏组件及体验问题修复,欢迎体验~
前端·javascript·人工智能
乡村中医4 小时前
AIChat渲染md格式优化-Web Worker
人工智能
老迟聊架构4 小时前
说说Vibe Coding的适应范围
人工智能·程序员·架构
数据智能老司机4 小时前
PyTorch 深度学习——使用神经网络来拟合数据
pytorch·深度学习