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

相关推荐
外参财观15 分钟前
流量变现的边界:携程金融按下暂停键后的冷思考
大数据·人工智能·金融
人工智能AI技术29 分钟前
能用C#开发AI吗?
人工智能·c#
whitelbwwww1 小时前
车牌识别--obb识别车框
人工智能
果粒蹬i1 小时前
AI系统故障诊断:模型崩溃、算力瓶颈与数据漂移的识别与解决策略
人工智能
CCPC不拿奖不改名1 小时前
两种完整的 Git 分支协作流程
大数据·人工智能·git·python·elasticsearch·搜索引擎·自然语言处理
Coding茶水间1 小时前
基于深度学习的交通标志检测系统演示与介绍(YOLOv12/v11/v8/v5模型+Pyqt5界面+训练代码+数据集)
开发语言·人工智能·深度学习·yolo·目标检测·机器学习
飞Link1 小时前
【论文笔记】《Deep Learning for Time Series Anomaly Detection: A Survey》
rnn·深度学习·神经网络·cnn·transformer
亿信华辰软件1 小时前
构建智慧数据中台,赋能饮料集团全链路数字化转型新引擎
大数据·人工智能·云计算
大模型实验室Lab4AI1 小时前
西北工业大学 StereoMV2D 突破 3D 物体检测深度难题,精度与效率兼得
人工智能·计算机视觉·目标跟踪
旷野说2 小时前
打造 36Gbps 超高速本地机器学习开发环境
人工智能·机器学习