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 分钟前
7.8 嵌套对话:智能体的内心独白与审查机制
人工智能
海兰3 分钟前
【高速缓存】RedisVL 存储类型选择指南:Hash 与 JSON
人工智能·redis·算法·缓存·json·哈希算法
KaMeidebaby6 分钟前
卡梅德生物技术快报|核酸适配体文库筛选:核酸适配体文库筛选全流程技术解析:NGS与AI辅助方案的设计与实践
前端·人工智能·物联网·算法·百度
Tangyuewei6 分钟前
交互熵:AI 编程工具的下一站不是聪明,是靠谱
人工智能·交互
淼澄研学9 分钟前
大模型应用开发实战:从API调用到RAG与Agent架构的5个核心落地方案
人工智能·架构
蓝速科技16 分钟前
蓝速 AI 双屏翻译机:铝型材精工机身为何碾压塑料公模
人工智能
Cosolar18 分钟前
Claude Opus 5 系统提示词被完整泄露,共 135027 字符、约 3.4 万 token
人工智能·后端·架构
奶糖 肥晨20 分钟前
mac系统中Java项目环境配置与问题解决全记录|环境准备篇:JDK与Maven安装配置
java·macos·maven
腾视科技AIoT22 分钟前
腾视科技重磅发布全场景无人叉车及智能调度系统解决方案,开启工业物流智能新时代
人工智能·科技·ai·无人车·ai算力·无人叉车·低速无人车
Hrain-AI24 分钟前
2026 企业级 AI Agent 本地化部署选型:6 维度 + 避坑清单
人工智能