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

相关推荐
潜龙95278 分钟前
手机自动化测试AI新方案
人工智能·智能手机
烂蜻蜓19 分钟前
AI入门教程(十):AI API开发:从“会用AI聊天”到“让AI在你的代码里干活”的完整指南
人工智能·ai
书签123635 分钟前
产教融合的技术解法:AI数字孪生驱动的校企协同育人系统架构与实践
人工智能·系统架构
东舟技术44 分钟前
AI全链路测试智能体上线啦!
人工智能·功能测试·测试工具·自动化
Elastic 中国社区官方博客1 小时前
Elastic 和 OpenAI 合作,将前沿智能引入非结构化企业数据
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai
Akamai中国1 小时前
为何弹性系统设计对云可靠性至关重要
人工智能·云计算·云服务
工业机器视觉设计和实现1 小时前
再攻下1分!
人工智能·cudnn微积分
VIP_CQCRE1 小时前
用 Ace Data Cloud 快速接入 Suno 声音克隆 API:让 AI 音乐拥有专属声线
人工智能·ai·aigc·api·音乐生成
wangqiaowq1 小时前
PostgreSQL 官方 Windows 安装
人工智能