Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question about model.fit in keras #7

Open
zhixiaochuan12 opened this issue Dec 25, 2018 · 2 comments
Open

A question about model.fit in keras #7

zhixiaochuan12 opened this issue Dec 25, 2018 · 2 comments

Comments

@zhixiaochuan12
Copy link

zhixiaochuan12 commented Dec 25, 2018

Hi, I want to extend your code to implement a binary link prediction task, the train_X is the indexes of nodes in graph with the shape of (train_size,2), each pair is like [node1_idx, node2_idx], and train_label's shape is (train_size,)

After the GraphConvolution Layer(the output is gc_output), I added a DistMult Layer to calculate the triple score e1 * R * e2, it was realized by gc_output[train_idx[:,0]] * R * gc_output[train_idx[:,1]]. The total Model(named model) consists of GraphConvolution layer and DistMult layer.

The problem I encountered was that when I fit data in Model like model.fit([X]+A, y_train), keras threw the errorValueError: Input arrays should have the same number of samples as target arrays. Found 74940 input samples and 11519 target samples. The sample_weight method used in your code seems no help for me. My friends suggested that pytorch can easily do this, but rewriting will cost more time.

I am new to keras, and I will really appreciate it if you can give me any suggestion related to this problem.

@tkipf
Copy link
Owner

tkipf commented Jan 3, 2019 via email

@zhixiaochuan12
Copy link
Author

Thanks for replying.

I finally repeated the y_train and forced the size of x_train and y_train be size-equal and wrote a new loss for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants