第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

數(shù)組在python中不可調(diào)用“'numpy.ndarray'對象不可調(diào)用”

數(shù)組在python中不可調(diào)用“'numpy.ndarray'對象不可調(diào)用”

素胚勾勒不出你 2021-09-11 14:53:59
我正在研究神經(jīng)網(wǎng)絡(luò),當我嘗試對兩個 numpy.ndarray 進行混洗時,出現(xiàn)此錯誤。我嘗試重新檢查 shuffle 函數(shù)格式,但找不到任何錯誤。請幫忙train_images,train_labels = shuffle(train_images,train_labels)TypeError                                 Traceback (most recent call last)<ipython-input-8-b3f4173331ac> in <module> 18     print("Training the Network") 19     for i in range(epoch): 20     --> train_images,train_labels = shuffle(train_images,train_labels) 21         for offset in range (0,no_eg,batch_size): 22             end = offset+batch_size/usr/lib/python3.5/random.py in shuffle(self, x, random)275             for i in reversed(range(1, len(x))):276                 # pick an element in x[:i+1] with which to exchange x[i]277            -->  j = _int(random() * (i+1))278                 x[i], x[j] = x[j], x[i]279 TypeError: 'numpy.ndarray' object is not callabl
查看完整描述

2 回答

?
慕村225694

TA貢獻1880條經(jīng)驗 獲得超4個贊

看看random.shuffle(x[, random])的文檔

可選參數(shù) random 是一個 0 參數(shù)函數(shù),返回 [0.0, 1.0) 中的隨機浮點數(shù);默認情況下,這是函數(shù) random()

在您的情況下,您通過 train_labels,根據(jù)錯誤消息,它是 numpy.ndarray,而不是函數(shù)


查看完整回答
反對 回復(fù) 2021-09-11
?
千萬里不及你

TA貢獻1784條經(jīng)驗 獲得超9個贊

shuffle您可能想要使用兩個已命名的函數(shù),但它們都沒有按您期望的方式工作。


random.shuffle(x, random=None)x使用函數(shù)洗牌列表random。


numpy.random.shuffle(x)打亂 NumPy 數(shù)組x。


這兩個函數(shù)一次只能打亂一個數(shù)組,但是你想打亂兩個數(shù)組,而且你想一致地打亂它們。考慮構(gòu)建一個熊貓系列,對系列進行混洗(“采樣”),然后再次將其拆分為值和標簽:


import pandas as pd

series = pd.Series(train_images, index=train_labels)

shuffled = series.sample(series.size)

train_images_shuffled = shuffled.values

train_labels_shuffled = shuffled.index


查看完整回答
反對 回復(fù) 2021-09-11
  • 2 回答
  • 0 關(guān)注
  • 346 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號