tkipf / c-swm Goto Github PK
View Code? Open in Web Editor NEWContrastive Learning of Structured World Models
License: MIT License
Contrastive Learning of Structured World Models
License: MIT License
You need to copy the following lines from data_gen/env.py
into data_gen/physics.py
:
# Get env directory
import sys
from pathlib import Path
if str(Path.cwd()) not in sys.path:
sys.path.insert(0, str(Path.cwd()))
Hi, Kipf~I really appreciate your work. I am wondering if the GNN is modeling interactions between objects.
After heading over the codes, I found that when collision happens from object A to object B, there's no bouncing back of object A and pushing forward happens to object B. So what are the interactions in 2d-boxpushing and 3d-boxingpushing experiments. The objects in those two experiments are more like independent with each other.
For 3-body physics, I understand the interactions are the forces among spheres.
Best regards.
Do you all use unique code for baseline implementations of World Models (with AE and VAE) or do you use a publicly accessible library? Can you point me toward the library/code you used? Would be useful for duplicating results.
(@abaheti95 you'll be interested too)
How do you determine the corresponding state representation of the manipulated object so that you can enter the unique thermal action code into GNN along with the abstract state of the corresponding target?
Hello Kipf, I find there is a discrepancy between the loss mentioned in the paper.
According to Eq(5) in paper, for negative samples, you calculate the Euclidean distance between negative state sample at timestep t
and state at timestep t+1
.
However, in the code below, state
and neg_state
are both at timestep t
.
self.neg_loss = torch.max(
zeros, self.hinge - self.energy(
state, action, neg_state, no_trans=True)).mean()
I noticed that the same question was also asked here.
I want to know if this is a bug ? Does the discrepancy affect the final performance ?
According to the paper, the negative component of the contrastive loss is the difference between the negative states (randomly sampled from embedding at timestamp t, (z_{t}~)) and the ground truth state (z_{t+1}).
However, as per the line 113 of modules.py, given no trans, you are effectively taking the difference between randomly sampled from embedding at timestamp t (z_{t}~) and z_{t} (rather than z_{t+1}).
` def contrastive_loss(self, obs, action, next_obs):
objs = self.obj_extractor(obs)
next_objs = self.obj_extractor(next_obs)
state = self.obj_encoder(objs)
next_state = self.obj_encoder(next_objs)
# Sample negative state across episodes at random
batch_size = state.size(0)
perm = np.random.permutation(batch_size)
neg_state = state[perm]
self.pos_loss = self.energy(state, action, next_state)
zeros = torch.zeros_like(self.pos_loss)
self.pos_loss = self.pos_loss.mean()
self.neg_loss = torch.max(
zeros, self.hinge - self.energy(
state, action, neg_state, no_trans=True)).mean()
loss = self.pos_loss + self.neg_loss
return loss
`
Thus, I feel instead of the state as the first argument of the energy function, next_state should have been the argument. Please let me know if I am misconstruing at any point.
Thanks.
When I try to run the code provided here, I end up hitting a RuntimeError here:
Line 104 in e944b24
python train.py --dataset data/shapes_train.h5 --encoder small --name shapes
Specifically, the error says: RuntimeError: DataLoader worker is killed by signal: Killed
. It seems to be coming from the fact that the dataloader is having trouble multi-processing the training set loading. But when I look through your utils files, I am not seeing why this error would exist.
This same error has occurred on both a windows machine as well as a linux machine.
Here's the full trace:
Traceback (most recent call last):
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 724, in _try_get_data
data = self.data_queue.get(timeout=timeout)
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/multiprocessing/queues.py", line 104, in get
if not self._poll(timeout):
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/multiprocessing/connection.py", line 257, in poll
return self._poll(timeout)
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/multiprocessing/connection.py", line 414, in _poll
r = wait([self], timeout)
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/multiprocessing/connection.py", line 921, in wait
ready = selector.select(timeout)
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/selectors.py", line 415, in select
fd_event_list = self._selector.poll(timeout)
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler
_error_if_any_worker_fails()
RuntimeError: DataLoader worker (pid 19014) is killed by signal: Killed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train.py", line 104, in <module>
obs = train_loader.__iter__().next()[0]
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 804, in __next__
idx, data = self._get_data()
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 771, in _get_data
success, data = self._try_get_data()
File "/home/aadharna/miniconda3/envs/cswm/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 737, in _try_get_data
raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str))
RuntimeError: DataLoader worker (pid(s) 19012, 19014) exited unexpectedly
(cswm) aadharna@penguin:~/PycharmProjects/c-swm$
I'll continue poking around and update when I find the root cause.
Hello, thank you for sharing the codes.
I really like the Figures 3 and 4 in your paper, and wonder if there is any scripts for reproducing these results.
Thanks!
Learn object representations and their relationship is intersting, but it is hard to understand how can you know all objcets at the begining for all examples.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.