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

相关推荐
冬奇Lab6 分钟前
Plugin 扩展实战:增强 Claude Code 的能力
人工智能·ai编程·claude
大好人ooo9 分钟前
企业级LLM评估与测试
人工智能
coding者在努力10 分钟前
LangChain简介,最直白的介绍
人工智能·python·语言模型·langchain
福大大架构师每日一题13 分钟前
dify 1.13.0——Human-in-the-Loop与工作流执行架构全面升级,释放AI与人的协作潜力
人工智能·架构
文艺倾年27 分钟前
【强化学习&SWE】如何无容器化进行强化学习训练
人工智能·分布式·大模型
童园管理札记33 分钟前
【记录模板】大班科学小游戏观察记录(盐主题:《会变魔术的盐》)
经验分享·深度学习·职场和发展·学习方法·微信公众平台
ZhengEnCi35 分钟前
06. Embedding模型与向量化
人工智能
人机与认知实验室36 分钟前
人类智能中依然存在还未被发现的新机制
人工智能
Dr.AE44 分钟前
AI+教育行业分析报告
大数据·人工智能·教育电商
永无魇足1 小时前
感知器算法
人工智能