mnick / scikit-kge

Python library to compute knowledge graph embeddings
MIT License
473 stars 142 forks source link

Correction in base.py file #3

Open svjan5 opened 7 years ago

svjan5 commented 7 years ago

Here: https://github.com/mnick/scikit-kge/blob/master/skge/base.py#L130 self.batch_size = np.ceil(len(xys) / self.nbatches) self.batch_size = int(np.ceil(len(xys) / self.nbatches))

In the latest stable version of numpy (1.13.0) np.ceil() returns a float value not int.

Because of this error, my code was crashing with:

TypeError: slice indices must be integers or None or have an index method

Please make the change.

grv1207 commented 6 years ago

I still see same self.batch_size = np.ceil(len(xys) / self.nbatches)

wanghaoyu0408 commented 6 years ago

I still found this mistake: "sub_arys.append(_nx.swapaxes(sary[st:end], axis, 0))" "slice indices must be integers or None or have an index method"

tridivb commented 5 years ago

This also happened with me for the following snippet in base.py.

def _optim(self, xys):
        idx = np.arange(len(xys), dtype=int)
        self.batch_size = np.ceil(len(xys) / self.nbatches)
        batch_idx = np.arange(self.batch_size, len(xys), self.batch_size, dtype=int)

I just introduced the dtype=int parameter to fix it.