Code Monkey home page Code Monkey logo

Comments (7)

talipucar avatar talipucar commented on July 18, 2024 1

Could you please share the error? Where does it occur?

from cpc.

talipucar avatar talipucar commented on July 18, 2024 1

OK, I think, you need to move hidden variable generated at line 101 of src/model.py to the device by using self.device.

For example:

hidden = th.zeros(2, bs, self.options["conv_dims"][-1])
hidden = hidden.to(self.device)

OR you can edit line 101 as following:

hidden = th.zeros((2, bs, self.options["conv_dims"][-1]), device=self.device)

So, either way should work. Please try, and see if it works. And if it does, please let me know.

from cpc.

talipucar avatar talipucar commented on July 18, 2024 1

Great! I will update the source code sometime soon.

Just a side note, in line 43 of ./utils/load_data.py, test_dataset is commented out.

If you want to use the test data, download "dev-clean" from original source where you downloaded the training set, and uncomment line 43. In this case, you need to change line 45 from return train_dataset, train_dataset to return train_dataset, test_dataset

I am closing this issue.

from cpc.

mattiasstahre avatar mattiasstahre commented on July 18, 2024

Hi, thanks for responding.

Traceback (most recent call last):
  File "0_train.py", line 72, in <module>
    main(config)
  File "0_train.py", line 53, in main
    train(config, data_loader, save_weights=True)
  File "0_train.py", line 29, in train
    encoder.fit(data_loader)
  File "/home/mattias/PyFlow_CPC/src/model.py", line 103, in fit
    encoder_samples, predictions, hidden = self.cpc(Xbatch, hidden)
  File "/home/mattias/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/mattias/PyFlow_CPC/utils/model_utils.py", line 60, in forward
    output, hidden = self.gru(prior_sequence, hidden)
  File "/home/mattias/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/mattias/anaconda3/lib/python3.8/site-packages/torch/nn/modules/rnn.py", line 837, in forward
    result = _VF.gru(input, hx, self._flat_weights, self.bias, self.num_layers,
RuntimeError: Input and hidden tensors are not at the same device, found input tensor at cuda:0 and hidden tensor at cpu

from cpc.

mattiasstahre avatar mattiasstahre commented on July 18, 2024

Getting further now but an error at:

Traceback (most recent call last):
  File "0_train.py", line 72, in <module>
    main(config)
  File "0_train.py", line 53, in main
    train(config, data_loader, save_weights=True)
  File "0_train.py", line 29, in train
    encoder.fit(data_loader)
  File "/home/mattias/PyFlow_CPC/src/model.py", line 122, in fit
    _ = self.validate(Xval) if epoch % self.options["nth_epoch"] == 0 else None
  File "/home/mattias/PyFlow_CPC/src/model.py", line 189, in validate
    encoder_samples, predictions, hidden = self.cpc(Xval, hidden)
  File "/home/mattias/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/mattias/PyFlow_CPC/utils/model_utils.py", line 60, in forward
    output, hidden = self.gru(prior_sequence, hidden)
  File "/home/mattias/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/mattias/anaconda3/lib/python3.8/site-packages/torch/nn/modules/rnn.py", line 837, in forward
    result = _VF.gru(input, hx, self._flat_weights, self.bias, self.num_layers,
RuntimeError: Input and hidden tensors are not at the same device, found input tensor at cuda:0 and hidden tensor at cpu

from cpc.

talipucar avatar talipucar commented on July 18, 2024

You have to do the same thing at line 187.

            # S=num_layers*num_directions, i.e. 2*1 since we are using 2 layers, and GRU is set as uni-directional
            hidden = th.zeros(2, self.options["batch_size"], self.options["conv_dims"][-1])

from cpc.

mattiasstahre avatar mattiasstahre commented on July 18, 2024

Worked great now! Thanks for the input.

from cpc.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.