- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试训练 DNNClassifier
labels = ['BENIGN', 'Syn', 'UDPLag', 'UDP', 'LDAP', 'MSSQL', 'NetBIOS', 'WebDDoS']
# Build a DNN
classifier = tf.estimator.DNNClassifier(
feature_columns=feature_columns,
hidden_units=[30, 10],
n_classes=len(labels),
label_vocabulary=labels)
def input_fn(features, labels, training=True, batch_size=32):
'''
An input function for training or evaluating
'''
# Convert the inputs to a Dataset.
dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels))
# Shuffle and repeat if you are in training mode.
if training:
dataset = dataset.shuffle(1000).repeat()
return dataset.batch(batch_size)
# Train the model
classifier.train(
input_fn=lambda: input_fn(train_features, train_label, training=True),
steps=5000)
训练工作正常,直到使用更大的数据集
train_features.shape
>>> (15891114, 20)
train_label.shape
>>> (15891114,)
我正在使用 Google Colaboratory,一旦培训开始,我的 session 就会因超过 RAM 使用量(12GB 的 RAM)而崩溃
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python
/ops/resource_variable_ops.py:1666: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.
Instructions for updating:
If using Keras pass *_constraint arguments to layers.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/training/training_util.py:236: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
INFO:tensorflow:Calling model_fn.
WARNING:tensorflow:Layer dnn is casting an input tensor from dtype float64 to the layer's dtype of float32, which is new behavior in TensorFlow 2. The layer has dtype float32 because it's dtype defaults to floatx.
If you intended to run this layer in float32, you can safely ignore this warning. If in doubt, this warning is likely only an issue if you are porting a TensorFlow 1.X model to TensorFlow 2.
To change all layers to have dtype float64 by default, call `tf.keras.backend.set_floatx('float64')`. To change just this layer, pass dtype='float64' to the layer constructor. If you are the author of this layer, you can disable autocasting by passing autocast=False to the base Layer constructor.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/optimizer_v2/adagrad.py:106: calling Constant.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
INFO:tensorflow:Done calling model_fn.
INFO:tensorflow:Create CheckpointSaverHook.
在训练开始之前,只使用了 1GB 的 RAM,但是一旦训练开始,RAM 就会迅速饱和。
chunks
使其工作用于训练/评估模型的数据框。
Estimator
时,我不清楚为什么 RAM 会饱和。 .
最佳答案
我复制了您的 Google Colab 并复制了“我的云端硬盘”中的数据文件并训练了估算器,您的代码正常工作::s .我可以毫无问题地训练 DNN:
我检查了我是否使用了大数据集:
我确实有一个 out of RAM
当我重新计算一些 jupyter notebook 单元时的消息,但是当我重新启动内核时从来没有,然后在此之后 Run all cells
.也许问题出在 jupyter 上?尝试将代码写入 .py 文件(放置在驱动器中),然后使用 subprocess
从 colab notebook 运行它,也许可以解决您的问题。
关于Tensorflow 2.0 - 大数据集的 tf.estimator.DNNClassifier 训练,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62190677/
几个月前,我使用了tf.contrib.learn.DNNRegressor来自 TensorFlow 的 API,我发现它使用起来非常方便。最近几个月我没有跟上TensorFlow的发展。现在我有一
我们正在尝试将旧的训练代码转换为更符合 tf.estimator.Estimator 的代码。在初始代码中,我们针对目标数据集微调原始模型。在使用 variables_to_restore 和 ini
我目前运行的是 TensorFlow 1.9.0。我的自定义估算器是使用 tf.estimator.Estimator 创建的,并且运行时没有出现任何故障。但是,我在 model_dir 下没有找到任
我刚刚用 tensorflow 训练了一个 CNN 来识别太阳黑子。我的模型与 this 几乎相同.问题是我无法在任何地方找到关于如何使用训练阶段生成的检查点进行预测的明确解释。 尝试使用标准恢复方法
我正在尝试使用我自己的数据集和类对在 imagenet 上预训练的 Inception-resnet v2 模型进行迁移学习。我的原始代码库是对 tf.slim 的修改我再也找不到的示例,现在我正在尝
在 train(...) 完成后,如何从 tf.estimator.Estimator 获取最后一个 global_step ?例如,典型的基于估算器的训练例程可能如下设置: n_epochs = 1
一年多来我一直在使用自己的 Estimator/Experiment 之类的代码,但我最终想加入 Dataset+Estimator 的行列。 我想做如下的事情: for _ in range(N):
我正在考虑将我的代码库移动到 tf.estimator.Estimator ,但我找不到如何将它与张量板摘要结合使用的示例。 MWE: import numpy as np import tensor
我的印象是在 tf.estimator.Estimator 实例上调用 evaluate() 不会在多个 GPU 上运行模型,即使分配策略是 MirroredStrategy,配置为至少使用 2 个
我遇到了一些小问题,但我不知道如何处理。 当我使用 tf.estimator.Estimator 时,它会在每个步骤中记录两行,例如: INFO:tensorflow:global_step/sec:
在此tutorial ,他们通过为 tf.nn.softmax 节点命名成功地记录了 softmax 函数。 tf.nn.softmax(logits, name="softmax_tensor")
我发现 tensorflow train_and_evaluate 的工作方式与传统的 tf.estimator train 和 evaluate 相比有点不同。train_and_evaluate
我正在使用 tensorflow 版本 2.0.0-beta1。打电话时 tf.estimator.inputs.pandas_input_fn 它给了我一个错误。 module 'tensorflo
有没有办法在另一个模型 B 中使用经过 tf.estimator 训练的模型 A? 这是情况,假设我有一个训练有素的“模型 A”和 model_a_fn()。“模型 A”获取图像作为输入,并输出一些类
我正在尝试在本地运行对象检测 API。 我相信我已经按照 TensorFlow Object Detection API 中的描述设置了所有内容。但是,当我尝试运行 model_main.py 时,会
请原谅我的编码经验。我正在尝试使用 GridSearch 进行一系列回归。我正在尝试循环整个过程以使过程更快,但我的代码不够好并且不介意提高效率。这是我的代码: classifiers=[Lasso(
我在将纯 Keras 模型转换为不平衡数据集上的 TensorFlow Estimator API 时遇到了一些麻烦。 使用纯 Keras API 时,class_weight 参数在 model.f
当发生上述错误时,我经常使用有关估计器的tensorflow官方教程,而它在google.colab中正常运行。 我使用的环境是win10-64bit&tensorflow-gpu==1.12.0&p
Closed. This question is opinion-based。它当前不接受答案。 想要改善这个问题吗?更新问题,以便editing this post用事实和引用来回答。 已关闭6年。
Closed. This question is opinion-based。它当前不接受答案。 想要改善这个问题吗?更新问题,以便editing this post用事实和引用来回答。 1年前关闭。
我是一名优秀的程序员,十分优秀!