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

相关推荐
神鹰手哥_起飞版43 分钟前
深度研判任务里,开思考、换更强的模型、套方法论,哪个更有用?
人工智能
ObserverX211 小时前
我是如何用 13KB 纯 Python,发现本地 RAG 的“隐式递归记忆”的
人工智能
Jason_gao9991 小时前
Github Copilot 新手极速上手指南
人工智能·github·copilot
用户360055579001 小时前
Kestrel_VLLM - 35 · 把 m 循环搬进内核:一次「先量发射、再合并发射」的完整回合
人工智能
Linye1 小时前
为什么让 AI 修个小 Bug 却把底层全重写了?聊聊 Coding Agent 的最小修改边界
人工智能·架构
深度开源1 小时前
我扫了自己电脑里的 402 个 AI 技能,光目录就吃掉 4.5 万 token
人工智能
skywalk81631 小时前
hive 常驻集群:像 OSPF 一样在线,像 git 一样可信
运维·人工智能·hive
王中阳Go1 小时前
你那条三跳链路的单跳超时,是按压测的 p95 定的,还是拍出来的?
人工智能·后端·架构
方方洛1 小时前
ray教程-27-附录F-RayClient与runtime_env与多语言
人工智能·分布式·机器学习
神鹰手哥_起飞版1 小时前
用 Agent 越多,硬盘越满?我在隐藏目录里发现了 334 GB 的 .mimosa
人工智能