progpy icon indicating copy to clipboard operation
progpy copied to clipboard

Tensorflow error on windows

Open teubert opened this issue 1 year ago • 1 comments

Seems to mostly be working, but I do get this error on (I think) all of the tensorflow tests:

======================================================================
ERROR: test_lstm_simple (tests.test_data_model.TestDataModel)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jason/code/nasa/progpy/tests/test_data_model.py", line 127, in test_lstm_simple
    m = self._test_simple_case(LSTMStateTransitionModel, window=5, epochs=20, max_error=3)
  File "/home/jason/code/nasa/progpy/tests/test_data_model.py", line 48, in _test_simple_case
    m2 = DataModelType.from_data(
  File "/home/jason/code/nasa/progpy/src/progpy/data_models/lstm_model.py", line 598, in from_data
    history = model.fit(
  File "/home/jason/code/nasa/progpy_venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/jason/code/nasa/progpy_venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py", line 117, in error_handler
    return fn(*args, **kwargs)
TypeError: TensorFlowTrainer.fit() got an unexpected keyword argument 'workers'

Could be related to the fact that I am running this in Windows WSL?

Originally posted by @jason-watkins in https://github.com/nasa/progpy/pull/154#issuecomment-2258699150

teubert avatar Jul 30 '24 16:07 teubert

Modify the fit Method to Handle 'workers' Argument

progpy/data_models/lstm_model.py

def fit(self, X, y, epochs=10, batch_size=32, workers=1, use_multiprocessing=False): """ Fit the model to the data. """ # Adjust the fit method to handle the 'workers' argument appropriately # For example, setting workers to 1 if on Windows if os.name == 'nt': workers = 1 # Proceed with the rest of the fitting process

  1. Explanation

What this does: Modifies the fit method to handle the 'workers' argument appropriately, especially on Windows systems.

Why this fixes it: Ensures compatibility with Windows systems where the 'workers' argument may cause issues.

Next steps: Test the modified method on Windows systems and update documentation as needed.

  1. Git Commands

git checkout -b fix/tensorflow-windows-compatibility

Modify the fit method in progpy/data_models/lstm_model.py as described above

git add progpy/data_models/lstm_model.py git commit -m "Fix TensorFlow 'workers' argument issue on Windows" git push origin fix/tensorflow-windows-compatibility