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

相关推荐
智算菩萨2 小时前
【实战讲解】ChatGPT 5.4深度文献检索完全指南:提示词工程与学术实战策略
论文阅读·人工智能·gpt·搜索引擎·chatgpt·提示词·论文笔记
gutsyang3 小时前
Google Stitch:最佳实践
人工智能·google·gemini·stitch
gloomyfish3 小时前
【最新认知】2026 | 深度学习工业缺陷检测三种技术路线分析与趋势
人工智能·深度学习
Deepoch3 小时前
Deepoc具身模型开发板:赋予机械狗“荒野求生”级VLA智能
人工智能·科技·开发板·具身模型·deepoc
阿里云大数据AI技术3 小时前
阿里云大数据AI平台升级发布:构筑智能体时代的核心基石
人工智能
AI自动化工坊3 小时前
DeerFlow 2.0实战指南:生产级AI Agent框架的Docker化部署与并行编排
人工智能·docker·ai·容器·开源
AI营销先锋3 小时前
原圈科技GEO解密:AI营销变革下,如何抢占增长先机?
大数据·人工智能
冬奇Lab4 小时前
一天一个开源项目(第56篇):人人都能用英语 - AI 时代的外语学习开源项目
人工智能·开源·资讯
前端摸鱼匠4 小时前
【AI大模型春招面试题12】Scaling Laws揭示了模型性能、数据量、计算量之间的什么关系?
人工智能·ai·语言模型·面试·大模型
yuhulkjv3354 小时前
deepseek怎么复制表格
人工智能·ai·chatgpt·豆包·deepseek·ai导出鸭