cerndb / dist-keras

Distributed Deep Learning, with a focus on distributed training, using Keras and Apache Spark.
http://joerihermans.com/work/distributed-keras/
GNU General Public License v3.0
624 stars 169 forks source link

Small typo in the `parameter_servers.py`: 'Sequential' object has no attribute 'get_weight' #17

Closed AlexandruBurlacu closed 7 years ago

AlexandruBurlacu commented 7 years ago

Well, I already found the solution, so I share my finding with you: When running the mnist.ipynb example, namely the optimizer cells, I have found a strange AttributeError : Sequential' object has no attribute 'get_weight. As I found out later, it was a typo, at line 230 of parameter_servers.py file, it should be get_weights. The Keras Sequential model doesn't have get_weight method.

After this fix, all the dist-keras optimizers were working properly.

BTW, I run Keras 2.0.2 with Theano 0.9.0 backend and Spark 2.1 and Python 2.7.12

Here is the full traceback:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-d05d8e848182> in <module>()
      2                    batch_size=4, communication_window=5, num_epoch=1,
      3                    features_col="features_normalized_dense", label_col="label_encoded")
----> 4 trained_model = trainer.train(training_set)

/home/alexburlacu/MDSC#April/dist-keras/distkeras/trainers.pyc in train(self, dataframe, shuffle)
    573         """
    574         # Allocate the parameter server.
--> 575         self.parameter_server = self.allocate_parameter_server()
    576         # Start the communication service.
    577         self.start_service()

/home/alexburlacu/MDSC#April/dist-keras/distkeras/trainers.pyc in allocate_parameter_server(self)
    423         this implementation.
    424         """
--> 425         parameter_server = DeltaParameterServer(self.master_model, self.master_port)
    426 
    427         return parameter_server

/home/alexburlacu/MDSC#April/dist-keras/distkeras/parameter_servers.pyc in __init__(self, model, master_port)
    228     def __init__(self, model, master_port):
    229         super(DeltaParameterServer, self).__init__(model, master_port)
--> 230         self.center_variable = np.asarray(self.model.get_weight())
    231 
    232     def handle_commit(self, conn, addr):

AttributeError: 'Sequential' object has no attribute 'get_weight'
JoeriHermans commented 7 years ago

This got fixed today afternoon https://github.com/cerndb/dist-keras/commit/465c43cd4894fa6bdd7355be0d977dc9972f6936 after someone reported the same issue. Thanks anyway for reporting this, I appreciate this!