Sketch_RNN,ValueError:无法提供形状值 [英] Sketch_RNN , ValueError: Cannot feed value of shape

查看:33
本文介绍了Sketch_RNN,ValueError:无法提供形状值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:

ValueError:无法为形状为(1, 117, 5)"的张量 u'vector_rnn_1/Placeholder_1:0' 提供形状 (1, 251, 5) 的值

从这里运行代码时https://github.com/tensorflow/magenta-演示/blob/master/jupyter-notebooks/Sketch_RNN.ipynb

该方法出现错误:

def encode(input_strokes):
  strokes = to_big_strokes(input_strokes).tolist()
  strokes.insert(0, [0, 0, 1, 0, 0])
  seq_len = [len(input_strokes)]
  draw_strokes(to_normal_strokes(np.array(strokes)))
  return sess.run(eval_model.batch_z, feed_dict={eval_model.input_data: [strokes], eval_model.sequence_lengths: seq_len})[0]

我不得不提一下,我按照此处的说明训练了自己的模型:

I have to mention I trained my own model following the instructions here:

https://github.com/tensorflow/magenta/tree/master/magenta/models/sketch_rnn

有人可以帮助我理解和解决这个问题吗?

Can someone help me into understanding and solving this issue ?

谢谢问候

推荐答案

就我而言,问题是由 to_big_strokes() 函数引起的.如果不修改sketch_rnn/utils.py中的to_big_stroke(),默认会将input_strokes序列延长到250.
您需要做的就是修改该函数中的参数 max_len.您需要将该值更改为您自己数据集的最大序列长度,对我来说是 21,如下所示标有更改"的行.

For my case, the problem is caused by to_big_strokes() function. If you do not modify the to_big_stroke() in sketch_rnn/utils.py, it will by default prolong the input_strokes sequence to the length of 250.
All you need to do, is to modify the parameter max_len in that function. You need to change that value to the maximum sequence length of your own dataset, which is 21 for me, as the line marked with "change" shown below.

def to_big_strokes(stroke, max_len=21):  # change: 250 -> 21
  """Converts from stroke-3 to stroke-5 format and pads to given length."""
  # (But does not insert special start token).

  result = np.zeros((max_len, 5), dtype=float)
  l = len(stroke)
  assert l <= max_len
  result[0:l, 0:2] = stroke[:, 0:2]
  result[0:l, 3] = stroke[:, 2]
  result[0:l, 2] = 1 - result[0:l, 3]
  result[l:, 4] = 1
  return result

这篇关于Sketch_RNN,ValueError:无法提供形状值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆