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

相关推荐
weixin_446260857 小时前
AtumAI:面向数据中心控制平面策略的规范化智能体生成框架
人工智能·平面
ZZHow10248 小时前
PyTorch深度学习入门笔记(小土堆)P7-14
人工智能·pytorch·笔记·python·深度学习
Dr.kangder8 小时前
AI4SE:AI赋能软件工程——从自动化到智能化的演进之路
人工智能·自动化·软件工程
GuWenyue8 小时前
大模型幻觉无解?7步搭建Milvus+LangChain电子书RAG,私有小说精准问答零编造
人工智能·langchain·ai编程
是Dream呀8 小时前
客户催着要数据,我用TRAE Work十分钟完成10万元项目
人工智能·架构·trae
IanSkunk8 小时前
眼健康机构系统化运营:流程拆解与协同机制怎么建?
大数据·人工智能
40kuai8 小时前
四款主流AI模型网关对比与选型指南
人工智能
2601_963282778 小时前
极寒区域无线通信系统工程实战:黑龙江冰雪环境对讲机组网、射频损耗与设备耐寒可靠性优化全指南
大数据·数据库·人工智能
海的辽阔8 小时前
GraphRAG 与 LightRAG 全面解析:传统 RAG 为什么开始走向图检索?
人工智能·rag
WA内核拾荒者8 小时前
WhatsApp 多语言 AI 对话的语言模型选择与本地化适配
人工智能·语言模型·php