简体   繁体   中英

TypeError: 'module' object is not callable . how to solve this problem

y_train = y_train.reshape(-1,)

    y_train[:5]
    
    y_test = y_test.reshape(-1,)
    
    nwclasses= classes
    nwclasses = ["airplane","automobile","bird","cat","deer","dog","frog","horse","ship","truck"]
    def plot_sample(X, y, index):
        plt.figure(figsize = (15,2))
        plt.imshow(X[index])
        plt.xlabel(classes[y[index]]) 
    plot_sample(X_train, y_train, 1)

**TypeError Traceback (most recent call last) in ----> 1 plot_sample(X_train, y_train, 1)

<ipython-input-34-4fb71385cd26> in plot_sample(X, y, index)
      1 def plot_sample(X, y, index):
----> 2     plt.figure(figsize = (15,2))
      3     plt.imshow(X[index])
      4     plt.xlabel(classes[y[index]])

TypeError: 'module' object is not callable**

figure is a module in matplotlib, us the figure.Figure class instead:

import matplotlib
matplotlib.figure.Figure(figsize = (15,2))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM