小编Her*_*tIs的帖子

Tensorflow 计算时内存不足:如何查找内存泄漏?

我正在使用 Google 的 TensorFlow DeepDream 实现(https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/deepdream/deepdream.ipynb)在目录中迭代做深度梦境图像。

我的代码如下:

model_fn = tensorflow_inception_graph.pb

# creating TensorFlow session and loading the model
graph = tf.Graph()
sess = tf.InteractiveSession(graph=graph)
with tf.gfile.FastGFile(model_fn, 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
t_input = tf.placeholder(np.float32, name='input') # define the input tensor
imagenet_mean = 117.0
t_preprocessed = tf.expand_dims(t_input-imagenet_mean, 0)
tf.import_graph_def(graph_def, {'input':t_preprocessed})



def render_deepdream(t_obj, img0=img_noise,
                     iter_n=10, step=1.5, octave_n=4, octave_scale=1.4):
    t_score = tf.reduce_mean(t_obj) # defining the optimization objective
    t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation!

    # …
Run Code Online (Sandbox Code Playgroud)

python memory-leaks out-of-memory tensorflow

0
推荐指数
1
解决办法
5891
查看次数

标签 统计

memory-leaks ×1

out-of-memory ×1

python ×1

tensorflow ×1