如何解决'range()整数结束参数预期,浮点'?

时间:2018-04-20 08:43:13

标签: python tensorflow

在执行Coursera CNN示例时,我在cnn_utils.py文件中收到以下错误。我做了将float转换为int所需的一切,但没有得到结果。请帮帮我

TypeError                                 Traceback (most recent call last)
<ipython-input-22-ddfc1f084c11> in <module>()
----> 1 _, _, parameters = model(X_train, Y_train, X_test, Y_test)

<ipython-input-12-a206d32574f3> in model(X_train, Y_train, X_test, Y_test, 
learning_rate, num_epochs, minibatch_size, print_cost)
 36             num_minibatches = int(m / minibatch_size) # number of 
minibatches of size minibatch_size in the train set
 37             seed = seed + 1
---> 38             minibatches = random_mini_batches(X_train, Y_train, 
minibatch_size, seed)
 39 
 40             for minibatch in minibatches:

/root/sharedfolder/cnn_utils.py in random_mini_batches(X, Y, mini_batch_size, seed)
 49     # Step 2: Partition (shuffled_X, shuffled_Y). Minus the end case.
 50     num_complete_minibatches = math.floor(m/mini_batch_size) # number of 
mini batches of size mini_batch_size in your partitionning
---> 51     for k in range(0, num_complete_minibatches):
 52         mini_batch_X = shuffled_X[k * mini_batch_size : k * 
mini_batch_size + mini_batch_size,:,:,:]
 53         mini_batch_Y = shuffled_Y[k * mini_batch_size : k * 
 mini_batch_size + mini_batch_size,:]

TypeError: range() integer end argument expected, got float.

0 个答案:

没有答案