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

相关推荐
richdata3 分钟前
鞋服品牌应该如何测算AI商品决策项目的ROI?
大数据·人工智能
AI天行健9 分钟前
星宇智算发布无限画布空间索引与语义检索架构技术白皮书
人工智能
hpoenixf12 分钟前
从 Trace 到可信观测:我们的 Agent 可观测体系怎样一步步建立起来
人工智能·agent
鬼手点金13 分钟前
Agent 的学习机制:后训练、上下文学习与外部化学习
java·人工智能·git·学习·自动化·nanogpt
Summer-Bright15 分钟前
英伟达拟收购Reflection、Step5开源license悬空、Codex CLI守护进程争议 —— AI 软件简报 10.10-10.14
人工智能·开源
Angeldream12324 分钟前
第 4 章 医学影像预处理
图像处理·人工智能·python·医学影像·医学影像处理
打工仔折腾 AI1 小时前
用 Dashlet 把极空间 NAS 服务入口整理成统一导航首页的实践
java·开发语言·人工智能·后端·python·rpc·ai agent 实战
野生码农AI实战1 小时前
【无标题】
大数据·人工智能
桃西西呀1 小时前
搜「怎么做接口限流」,向量库却把「怎么做缓存」的段落递了上来
人工智能·llm·ai编程
像风一样自由20201 小时前
56.实战PostgreSQL-pgvector-FastAPI构建轻量级RAG
数据库·人工智能·postgresql·大模型·fastapi·智能体