2017-03-26 5 views
1

テンソルフローの開始v3のpool_3レイヤ出力を取得しようとしています。私の入力は、形状のndarray(64,64,3)であるが、私はエラーTensorflowの開始時のエラーV3 pool_3レイヤの出力中に取得する

with tf.Session() as sess: 
    pool_3_tensor = sess.graph.get_tensor_by_name('pool_3:0') 

    feat1 = sess.run(pool_3_tensor,{'DecodeJpeg/contents:0': image}) 
    feat1 = np.squeeze(feat1) 

ValueError        Traceback (most recent call last) 
<ipython-input-26-fb1865f7fbee> in <module>() 
     3  pool_3_tensor = sess.graph.get_tensor_by_name('pool_3:0') 
     4 
----> 5  feat1 = sess.run(pool_3_tensor,{'DecodeJpeg/contents:0': image}) 
     6  feat1 = np.squeeze(feat1) 

/N/u/mbirla/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata) 
    765  try: 
    766  result = self._run(None, fetches, feed_dict, options_ptr, 
--> 767       run_metadata_ptr) 
    768  if run_metadata: 
    769   proto_data = 
    tf_session.TF_GetBuffer(run_metadata_ptr) 

/N/u/mbirla/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 
    942     'Cannot feed value of shape %r for Tensor %r, ' 
    943     'which has shape %r' 
--> 944     % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape()))) 
    945   if not self.graph.is_feedable(subfeed_t): 
    946    raise ValueError('Tensor %s may not be fed.' % subfeed_t) 

ValueError: Cannot feed value of shape (64, 64, 3) for Tensor 'DecodeJpeg/contents:0', which has shape '() 

-------アップデート----------

次取得します

文字列に変換した後。私は、詳細なエラーのためにサイズ12288. 無効なJPEGデータを取得しています:

feat1 = sess.run(pool_3_tensor,{'DecodeJpeg/contents:0': image.tostring()}) 

https://gist.github.com/mridulbirla/0d710d7ccd7b22c8f87989c37837e10e

答えて

0

変更

feat1 = sess.run(pool_3_tensor,{'DecodeJpeg/contents:0': image}) 

をして

'DecodeJpeg/contents:0'を試したことは、スカラ文字列テンソルでありますそこから3つの薄暗いテンソルを解読できます

私は当初-V3で学習転送をしたとき

、私は、代わりに、np.array型に画像を読み取る

with tf.gfile.FastGFile("you_image_file_name") as f: 
    content = f.read() 

で文字列に画像コンテンツを読んでいない、その後'DecodeJpeg/contents:0'contentを養います

+0

文字列に変換すると、InvalidArgument Errorが表示されます。スタックトレースの詳細[エラーリンク](https://gist.github.com/mridulbirla/0d710d7ccd7b22c8f87989c37837e10e) –

関連する問題