-
Notifications
You must be signed in to change notification settings - Fork 612
normalize之后_train_samples纬度会发生改变,不能直接用imshow #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python2.7情况下,normalize直接用inspect会报错,维度问题 normalize之前_train_samples的纬度(73257, 32, 32, 3) 之后纬度为(73257, 32, 32, 1) 将其转化为(73257, 32, 32)即可画出图
Owner
CreatCodeBuild
commented
Oct 20, 2016
不应该直接修改 _train_samples,因为要在 TF 中使用 4 维的 Tensor。
应该在 Inspect 中判断 shape[3] 是否为 1。
imshow 接受的 shape 有 (x, y), (x, y, 3) and (x, y, 4)
如果shape[3] == 1, 那么 reshape
def inspect(dataset, labels, i):
# 显示图片看看
if dataset.shape[3] == 1:
shape = dataset.shape
dataset = dataset.reshape(shape[0], shape[1], shape[2])
print(labels[i])
plt.imshow(dataset[i])
plt.show()
SMZCC
commented
Aug 31, 2017
你好,为啥按照这个代码显示的灰度图还是有颜色啊?
Owner
CreatCodeBuild
commented
Aug 31, 2017
@SMZCC 这是plt函数实现造成的。不是bug。不用在意。
SMZCC
commented
Sep 1, 2017
- 蟹蟹,我知道了;
- 另外,我发现,在plt.imshow(samples[i])中,添加第二个参数,plt.imshow(samples[i], plt.cm.gray)就会灰度显示了;
- 可是,我还有个问题:我调用了inspect函数两次,理论来说应该会显示两个图片,然而,每次我都需要将第一张图片(3通道的图片)关闭掉才会显示第二张图片(单通道的),怎么让他们同时显示呢?
Owner
@SMZCC 这个你可以google一下。matplotlib不是很易用。我之前遇到过同样的问题,但是忘记了。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
python2.7情况下,normalize直接用inspect会报错,维度问题
normalize之前_train_samples的纬度(73257, 32, 32, 3)
之后纬度为(73257, 32, 32, 1)
将其转化为(73257, 32, 32)即可画出图