Skip to content

MABIGRU - AttributeError: 'tuple' object has no attribute 'shape' #8

@MinuteswithMetrics

Description

@MinuteswithMetrics

Thank you for sharing your code. I tried to see if I can achieve the same results but I ran into
AttributeError: 'tuple' object has no attribute 'shape' error. I also tried using the Quora training set and ran into the same error as well.

I was also wondering if this datasets = [train_df, test_df] on line 15 in bigru_manhattan.py. Should it be sick_train and sick_test?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-1d2d0f3fe90c> in <module>
     16 for i in range(0, 3):
     17     sims, trained_model, topic = run_experiment(sick_train_normlized, sick_test_normalized, ['sent_1', 'sent_2'], "sim",
---> 18                                                 benchmarks[i])
     19     sick_test_normalized['predicted_sim'] = pd.Series(sims).values
     20     pearson_correlation = scipy.stats.pearsonr(sims, sick_test_normalized['sim'])[0]

/floyd/home/utility/run_experiment.py in run_experiment(train_df, test_df, sent_cols, sim_col, benchmark)
      1 def run_experiment(train_df, test_df, sent_cols, sim_col, benchmark):
----> 2     sims, trained_model = benchmark[1](train_df, test_df, sent_cols, sim_col)
      3     return sims, trained_model, benchmark[0]

/floyd/home/nn/bigru_manhattan.py in run_bigru_benchmark(train_df, test_df, sent_cols, sim_col, validation_portion, n_hidden, embedding_dim, batch_size, n_epoch, optimizer, save_weights, load_weights, max_seq_length, model)
     52 
     53     # Embedded version of the inputs
---> 54     encoded_left = embedding_layer(left_input)
     55     encoded_right = embedding_layer(right_input)
     56 

/usr/local/lib/python3.6/site-packages/keras/engine/base_layer.py in __call__(self, inputs, **kwargs)
    434                 # Load weights that were specified at layer instantiation.
    435                 if self._initial_weights is not None:
--> 436                     self.set_weights(self._initial_weights)
    437 
    438             # Raise exceptions in case the input is not compatible

/usr/local/lib/python3.6/site-packages/keras/engine/base_layer.py in set_weights(self, weights)
   1051         param_values = K.batch_get_value(params)
   1052         for pv, p, w in zip(param_values, params, weights):
-> 1053             if pv.shape != w.shape:
   1054                 raise ValueError('Layer weight shape ' +
   1055                                  str(pv.shape) +

AttributeError: 'tuple' object has no attribute 'shape'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions