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

相关推荐
Codebee5 分钟前
Ooder框架8步编码流程实战 - DSM组件UI统计模块深度解析
人工智能
Deepoch30 分钟前
智能升级新范式:Deepoc开发板如何重塑康复辅具产业生态
人工智能·具身模型·deepoc·智能轮椅
赋创小助手30 分钟前
融合与跃迁:NVIDIA、Groq 与下一代 AI 推理架构的博弈与机遇
服务器·人工智能·深度学习·神经网络·语言模型·自然语言处理·架构
静听松涛13334 分钟前
多智能体协作中的通信协议演化
人工智能
基咯咯43 分钟前
Google Health AI发布MedASR:Conformer 医疗语音识别如何服务临床口述与对话转写
人工智能
白日做梦Q1 小时前
深度学习模型评估指标深度解析:不止于准确率的科研量化方法
人工智能·深度学习
Yyyyy123jsjs1 小时前
外汇Tick数据交易时段详解与Python实战分析
人工智能·python·区块链
张彦峰ZYF1 小时前
提示词工程实战指南:从概念认知到可验证的高质量 Prompt 设计
人工智能·提示词工程实战指南·高质量 prompt 设计
哥布林学者2 小时前
吴恩达深度学习课程四:计算机视觉 第四周:卷积网络应用 (二) 图像风格转换
深度学习·ai
不易思不逸2 小时前
SAM2 测试
人工智能·python