请选择 进入手机版 | 继续访问电脑版

大蛇智能

 找回密码
 立即注册

扫一扫,访问微社区

搜索
热搜: 活动 交友 discuz
查看: 530|回复: 3

代码4-10.py报错

[复制链接]

3

主题

7

帖子

33

积分

新手上路

Rank: 1

积分
33
发表于 2020-12-15 16:56:45 | 显示全部楼层 |阅读模式
由于没有woman和man的图片,随便设置了2个jpg文件夹。随便从网上下载了一些jpg文件。执行random rotate部分代码时报错。报错日志

  1. WARNING:tensorflow:From D:\environment\Anaconda3\lib\site-packages\tensorflow\python\compat\v2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
  2. Instructions for updating:
  3. non-resource variables are not supported in the long term
  4. 2020-12-15 16:55:15.982574: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX2
  5. To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
  6. 2020-12-15 16:55:15.990829: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x184e09f0860 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
  7. 2020-12-15 16:55:15.991382: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
  8. 2020-12-15 16:55:17.098415: W tensorflow/core/framework/op_kernel.cc:1755] Invalid argument: ValueError: buffer source array is read-only
  9. Traceback (most recent call last):

  10.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 242, in __call__
  11.     return func(device, token, args)

  12.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 131, in __call__
  13.     ret = self._func(*args)

  14.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 302, in wrapper
  15.     return func(*args, **kwargs)

  16.   File "C:\Users\Z30004~1\AppData\Local\Temp\tmp0efu2bp_.py", line 20, in _rotated
  17.     image_rotated = ag__.converted_call(ag__.ld(transform).warp, (ag__.ld(image), (ag__.ld(tf_shift) + (ag__.ld(tf_rotate) + ag__.ld(tf_shift_inv))).inverse), None, fscope_1)

  18.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 461, in converted_call
  19.     return _call_unconverted(f, args, kwargs, options, False)

  20.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 340, in _call_unconverted
  21.     return f(*args)

  22.   File "D:\environment\Anaconda3\lib\site-packages\skimage\transform\_warps.py", line 860, in warp
  23.     dims.append(_warp_fast[ctype](image[..., dim], matrix,

  24.   File "skimage\transform\_warps_cy.pyx", line 70, in skimage.transform._warps_cy._warp_fast

  25.   File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper

  26.   File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__

  27. ValueError: buffer source array is read-only


  28. loading sample  dataset..
  29. loading sample  dataset..
  30. loading sample  dataset..
  31. Traceback (most recent call last):
  32.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1365, in _do_call
  33.     return fn(*args)
  34.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1349, in _run_fn
  35.     return self._call_tf_sessionrun(options, feed_dict, fetch_list,
  36.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1441, in _call_tf_sessionrun
  37.     return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
  38. tensorflow.python.framework.errors_impl.InvalidArgumentError: ValueError: buffer source array is read-only
  39. Traceback (most recent call last):

  40.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 242, in __call__
  41.     return func(device, token, args)

  42.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 131, in __call__
  43.     ret = self._func(*args)

  44.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 302, in wrapper
  45.     return func(*args, **kwargs)

  46.   File "C:\Users\Z30004~1\AppData\Local\Temp\tmp0efu2bp_.py", line 20, in _rotated
  47.     image_rotated = ag__.converted_call(ag__.ld(transform).warp, (ag__.ld(image), (ag__.ld(tf_shift) + (ag__.ld(tf_rotate) + ag__.ld(tf_shift_inv))).inverse), None, fscope_1)

  48.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 461, in converted_call
  49.     return _call_unconverted(f, args, kwargs, options, False)

  50.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 340, in _call_unconverted
  51.     return f(*args)

  52.   File "D:\environment\Anaconda3\lib\site-packages\skimage\transform\_warps.py", line 860, in warp
  53.     dims.append(_warp_fast[ctype](image[..., dim], matrix,

  54.   File "skimage\transform\_warps_cy.pyx", line 70, in skimage.transform._warps_cy._warp_fast

  55.   File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper

  56.   File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__

  57. ValueError: buffer source array is read-only


  58.          [[{{node cond/else/_1/cond/EagerPyFunc}}]]
  59.          [[IteratorGetNext_1]]

  60. During handling of the above exception, another exception occurred:

  61. Traceback (most recent call last):
  62.   File "D:/book/tf2/TensorFlow2x_Engineering_Implementation-master/code/代码4-10  将图片文件制作成Dataset数据集.py", line 160, in <module>
  63.     value2 = sess.run(one_element2)
  64.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 957, in run
  65.     result = self._run(None, fetches, feed_dict, options_ptr,
  66.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1180, in _run
  67.     results = self._do_run(handle, final_targets, final_fetches,
  68.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1358, in _do_run
  69.     return self._do_call(_run_fn, feeds, fetches, targets, options,
  70.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1384, in _do_call
  71.     raise type(e)(node_def, op, message)
  72. tensorflow.python.framework.errors_impl.InvalidArgumentError: ValueError: buffer source array is read-only
  73. Traceback (most recent call last):

  74.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 242, in __call__
  75.     return func(device, token, args)

  76.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 131, in __call__
  77.     ret = self._func(*args)

  78.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 302, in wrapper
  79.     return func(*args, **kwargs)

  80.   File "C:\Users\Z30004~1\AppData\Local\Temp\tmp0efu2bp_.py", line 20, in _rotated
  81.     image_rotated = ag__.converted_call(ag__.ld(transform).warp, (ag__.ld(image), (ag__.ld(tf_shift) + (ag__.ld(tf_rotate) + ag__.ld(tf_shift_inv))).inverse), None, fscope_1)

  82.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 461, in converted_call
  83.     return _call_unconverted(f, args, kwargs, options, False)

  84.   File "D:\environment\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 340, in _call_unconverted
  85.     return f(*args)

  86.   File "D:\environment\Anaconda3\lib\site-packages\skimage\transform\_warps.py", line 860, in warp
  87.     dims.append(_warp_fast[ctype](image[..., dim], matrix,

  88.   File "skimage\transform\_warps_cy.pyx", line 70, in skimage.transform._warps_cy._warp_fast

  89.   File "stringsource", line 658, in View.MemoryView.memoryview_cwrapper

  90.   File "stringsource", line 349, in View.MemoryView.memoryview.__cinit__

  91. ValueError: buffer source array is read-only


  92.          [[{{node cond/else/_1/cond/EagerPyFunc}}]]
  93.          [[IteratorGetNext_1]]
复制代码


回复

使用道具 举报

1

主题

2

帖子

9

积分

新手上路

Rank: 1

积分
9
发表于 2020-12-16 09:11:32 | 显示全部楼层
楼主我也遇到了同样的问题,请问解决了吗
回复

使用道具 举报

3

主题

7

帖子

33

积分

新手上路

Rank: 1

积分
33
 楼主| 发表于 2020-12-18 14:41:16 | 显示全部楼层
追风筝的人 发表于 2020-12-16 09:11
楼主我也遇到了同样的问题,请问解决了吗

没解决,使用了第二种旋转方式,是可以的。
回复

使用道具 举报

143

主题

242

帖子

759

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
759
发表于 2020-12-18 16:51:49 | 显示全部楼层
代码确实有问题。2.1以后已经不支持这种方式了。2.0还可以。可以使用这种tfa的方式
代码4-10 将图片文件制作成Dataset数据集-TFa.py (6.48 KB, 下载次数: 17)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|大蛇智能 ( 京ICP备18026897号-1 )

GMT+8, 2021-4-18 00:59 , Processed in 0.029274 second(s), 27 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表