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

相关推荐
码农小白AI5 分钟前
标准错配、限值误判难被普通工具识别,IACheck AI 报告文档审核精准对标国标
人工智能
hangyuekejiGEO7 分钟前
临沂GEO服务企业技术选型分析
人工智能·python
极客侃科技16 分钟前
2026知识付费拼团系统哪个好用?裂变营销工具实测
人工智能
sunywz30 分钟前
【AI RAG知识库】05.【导入】【节点7】node_import_milvus.md
人工智能·milvus
KaMeidebaby36 分钟前
卡梅德生物技术快报|蛋白的叠氮基修饰:实操解析:核酸模板耦合蛋白的叠氮基修饰实现靶蛋白定点共价标记
前端·人工智能·物联网·算法·百度
让学习成为一种生活方式44 分钟前
望春玉兰基因组--文献精读258
人工智能
Token炼金师1 小时前
推理部署层:吞吐上不去的显存账本与调度博弈
人工智能·深度学习·llm
OpenCloudOS1 小时前
OpenCloudOS 理事会更新 | 腾讯云、海光助力建设 AI Infra 开源开放底座
人工智能·开源·腾讯云
私人珍藏库1 小时前
[Android] 一木百宝箱-万能百宝箱+抖音去水印等几百种功能
android·人工智能·app·软件·多功能
没落英雄2 小时前
3. DeepAgents 实战 - Memory Skills 与上下文工程
前端·人工智能·架构