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

相关推荐
ZhengEnCi5 分钟前
L2A-一个域名如何访问多台云服务器-子域名、路径前缀与Nginx反向代理选型指南
linux·人工智能
2601_9637491012 分钟前
越华环保集团污水站曝气系统边缘闭环控制架构与能耗优化实现
人工智能·架构
工业涂料百问15 分钟前
【生产施工】系列(六)工业涂料固化方式怎么选?自然干 / UV / 电子束原理与选型实战
人工智能
葡萄城技术团队39 分钟前
活字格 12.1 新特性解密:禁用自动回复后,AI 对话单元格也能流式输出了
人工智能
东风破_1 小时前
从 RAG 到 Agentic RAG:第一步,让模型决定「要不要检索」
人工智能
火山引擎开发者社区1 小时前
一图看懂 ADrive 跨产品协作实践:文件通了,Agent 就通了
人工智能
蒲公英内测分发1 小时前
App 更新一次就换一个二维码?智能硬件配套 App 的版本和下载入口怎么管理
人工智能·测试工具·智能家居·智能硬件
Tp_jh1 小时前
AMD 395本地部署Qwen3.8-Flash-Next实测,端侧AGI时代也要来了
图像处理·人工智能·opencv·语言模型·自然语言处理·千问
xcLeigh1 小时前
让大模型长出手脚,自己写SQL查数据库(Function Calling初探)
数据库·人工智能·sql·时序数据库·timechoai
锋行天下1 小时前
LangGraph 模拟大模型调用工具失败后重试直到成功
人工智能