Skip to content
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

TypeError: 'numpy.ndarray' object is not callable! #79

Closed
innat opened this issue Nov 14, 2018 · 0 comments
Closed

TypeError: 'numpy.ndarray' object is not callable! #79

innat opened this issue Nov 14, 2018 · 0 comments

Comments

@innat
Copy link

innat commented Nov 14, 2018

I was trying to implement CapsuleNet for classifying digits. All the images are RGB images and resize to 32 X 32 and dataset has 10 classification output.

X_train_all.shape: (745, 32, 32, 3)

y_train_all.shape: (745, 10)

First, define the CapsNet model which takes the following parameters.

# define model
model = CapsNet()

Ok, I think this chunk of information only enough here. However, then I define a function for data augmentation and both training the model. This function will iteratively train on the shuffling fold of the data set, defined below.

kfold = KFold(n_splits=10, shuffle=True, random_state=42)
for train, val in kfold.split(X_train_all, y_train_all):
    print ('Fold: ', Fold)
    
    X_train = X_train_all[train]
    X_val = X_train_all[val]

    y_train = y_train_all[train]
    y_val = y_train_all[val]

    # train the model with data augmentation    
    train()

    Fold = Fold + 1

The train function above, defined by you as follows:

def train(model, data, epoch_size_frac=1.0):

    # unpacking the data
    (x_train, y_train), (x_val, y_val) = data

    # compile the model
    model.compile()
    

    def train_generator(x, y, batch_size, shift_fraction=0.):
        train_datagen = ImageDataGenerator

    # Training with data augmentation. 
    model.fit_generator

    return model

Now, when I start training, I get following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-67-a8ca211d12a2> in <module>()
     19 
     20 
---> 21     train(model = model, data = ((X_train, y_train), (X_val, y_val)), epoch_size_frac = 0.5)
     22 
     23 

TypeError: 'numpy.ndarray' object is not callable
@innat innat closed this as completed Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant