私はPythonの初心者です。私は次のコードを試しました。しかし、私はそれが私の機能で "for"ループをしないようになるのを理解できません。どうして私のPythonコードでループしないのですか
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import os
import sys
import tarfile
from IPython.display import display, Image
from scipy import ndimage
from sklearn.linear_model import LogisticRegression
from six.moves.urllib.request import urlretrieve
from six.moves import cPickle as pickle
def checkOverlap(sample, setToTest):
errorThresh = 0.0001
dataShape = setToTest.shape
numOfIms = dataShape[0]
print('Number of arrays:' numOfIms)
#How come it does not do the following loop?
for idx2 in range(numOfIms):
print('Iteration: ',idx2)
im = setToTest[idx2,:,:]
err = np.subtract(sample,im)
errAbs = np.abs(err)
maxErr = np.max(errAbs)
if maxErr < errorThresh:
# print('Image Idx: ', idx,' is overlapping image with maxErr = ', maxErr)
plt.figure(3)
plt.imshow(errAbs)
plt.draw()
return True, idx2
else:
# print('Image Idx: ', idx,' is not overlapping image with maxErr = ', maxErr)
return False, idx2
setToTest= np.ndarray((10,2,2), dtype=np.int32)
sample = np.ndarray((2,2), dtype = np.int32)
checkOverlap(sample,setToTest)
次のように出力したばかりである:配列の
数:10
反復:0
はあなたが私が私が行方不明です何を聞かせてもらえますか?
ありがとうございます。
コードを再フォーマットできますか? – KIDJourney
あなたはループの中に戻ります。もちろん、それは1回の反復を行い、それが終了します。 – kindall
'maxErr