Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Define loss function in Python #1868

Merged
merged 2 commits into from
Apr 16, 2016
Merged

Define loss function in Python #1868

merged 2 commits into from
Apr 16, 2016

Conversation

pluskid
Copy link
Contributor

@pluskid pluskid commented Apr 15, 2016

We already have the ability to define symbolic operators in Python. But due to multi-threading issue, this feature cause a lot of pain to implement in other languages like Julia (e.g. dmlc/MXNet.jl#16). With the new module system, we can achieve similar thing (at least for the case of simple linear chaining) by defining a loss module directly in Python.

This PR is a simple demo of defining a multiclass-hinge loss and train on MNIST.

Later on (???) I will try to port the module system to Julia.

@tqchen
Copy link
Member

tqchen commented Apr 15, 2016

Looks nice, will this works naturally with the data parallel case?

@tqchen
Copy link
Member

tqchen commented Apr 15, 2016

Also cc @jermainewang Maybe minpy could be used here as well ?

@pluskid
Copy link
Contributor Author

pluskid commented Apr 16, 2016

@tqchen yes, the computation graph module is independent of the loss module. The first part can do data parallel as usual, the latter part can also do whatever they like. I guess for example people could implement the loss function with pycuda etc.

@pluskid
Copy link
Contributor Author

pluskid commented Apr 16, 2016

I guess it might be possible to define a minpy module that wraps Amy minpy function and utilize the auto grad feature of minpy.

@tqchen
Copy link
Member

tqchen commented Apr 16, 2016

Yes, that is what I mean. Could be interesting for a separate PR

pluskid added 2 commits April 16, 2016 00:13
Squashed commits:
[960414a] simplify the user interface for defining python loss module
[dbb797e] test python loss on gpu
[f5d94a8] fix lint errors (+1 squashed commit)
Squashed commits:
[5d7c7ea] add an example to define loss function in Python
@pluskid pluskid merged commit ec8302b into apache:master Apr 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants