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

Added a bunch of missing functions #183

Merged
merged 2 commits into from
Nov 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions python/_dynet.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ cdef extern from "dynet/expr.h" namespace "dynet::expr":
CExpression c_tanh "dynet::expr::tanh" (CExpression& x) #
CExpression c_exp "dynet::expr::exp" (CExpression& x) #
CExpression c_square "dynet::expr::square" (CExpression& x) #
CExpression c_sqrt "dynet::expr::sqrt" (CExpression& x) #
CExpression c_erf "dynet::expr::erf" (CExpression& x) #
CExpression c_cube "dynet::expr::cube" (CExpression& x) #
CExpression c_log "dynet::expr::log" (CExpression& x) #
CExpression c_lgamma "dynet::expr::lgamma" (CExpression& x) #
CExpression c_logistic "dynet::expr::logistic" (CExpression& x) #
CExpression c_rectify "dynet::expr::rectify" (CExpression& x) #
#CExpression c_hinge "dynet::expr::hinge" (CExpression& x, unsigned index, float m=?) #
Expand All @@ -225,6 +228,7 @@ cdef extern from "dynet/expr.h" namespace "dynet::expr":
CExpression c_softmax "dynet::expr::softmax" (CExpression& x) #
CExpression c_sparsemax "dynet::expr::sparsemax" (CExpression& x) #
CExpression c_softsign "dynet::expr::softsign" (CExpression& x) #
CExpression c_pow "dynet::expr::pow" (CExpression& x, CExpression& y) #
CExpression c_bmin "dynet::expr::min" (CExpression& x, CExpression& y) #
CExpression c_bmax "dynet::expr::max" (CExpression& x, CExpression& y) #
CExpression c_noise "dynet::expr::noise" (CExpression& x, float stddev) #
Expand All @@ -240,6 +244,7 @@ cdef extern from "dynet/expr.h" namespace "dynet::expr":

CExpression c_dot_product "dynet::expr::dot_product" (CExpression& x, CExpression& y) #
CExpression c_squared_distance "dynet::expr::squared_distance" (CExpression& x, CExpression& y) #
CExpression c_squared_norm "dynet::expr::squared_norm" (CExpression& x) #
CExpression c_huber_distance "dynet::expr::huber_distance" (CExpression& x, CExpression& y, float c) #
CExpression c_l1_distance "dynet::expr::l1_distance" (CExpression& x, CExpression& y) #
CExpression c_binary_log_loss "dynet::expr::binary_log_loss" (CExpression& x, CExpression& y) #
Expand Down
5 changes: 5 additions & 0 deletions python/_dynet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ cpdef Expression colwise_add(Expression x, Expression y): ensure_freshness(y); r

cpdef Expression trace_of_product(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_trace_of_product(x.c(), y.c()))
cpdef Expression dot_product(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_dot_product(x.c(), y.c()))
cpdef Expression squared_norm(Expression x): return Expression.from_cexpr(x.cg_version, c_squared_norm(x.c()))
cpdef Expression squared_distance(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_squared_distance(x.c(), y.c()))
cpdef Expression l1_distance(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_l1_distance(x.c(), y.c()))
cpdef Expression binary_log_loss(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_binary_log_loss(x.c(), y.c()))
Expand All @@ -869,8 +870,11 @@ cpdef Expression filter1d_narrow(Expression x, Expression y): ensure_freshness(y
cpdef Expression tanh(Expression x): return Expression.from_cexpr(x.cg_version, c_tanh(x.c()))
cpdef Expression exp(Expression x): return Expression.from_cexpr(x.cg_version, c_exp(x.c()))
cpdef Expression square(Expression x): return Expression.from_cexpr(x.cg_version, c_square(x.c()))
cpdef Expression sqrt(Expression x): return Expression.from_cexpr(x.cg_version, c_sqrt(x.c()))
cpdef Expression erf(Expression x): return Expression.from_cexpr(x.cg_version, c_erf(x.c()))
cpdef Expression cube(Expression x): return Expression.from_cexpr(x.cg_version, c_cube(x.c()))
cpdef Expression log(Expression x): return Expression.from_cexpr(x.cg_version, c_log(x.c()))
cpdef Expression lgamma(Expression x): return Expression.from_cexpr(x.cg_version, c_lgamma(x.c()))
cpdef Expression logistic(Expression x): return Expression.from_cexpr(x.cg_version, c_logistic(x.c()))
cpdef Expression rectify(Expression x): return Expression.from_cexpr(x.cg_version, c_rectify(x.c()))
cpdef Expression log_softmax(Expression x, list restrict=None):
Expand All @@ -881,6 +885,7 @@ cpdef Expression log_softmax(Expression x, list restrict=None):
cpdef Expression softmax(Expression x): return Expression.from_cexpr(x.cg_version, c_softmax(x.c()))
cpdef Expression sparsemax(Expression x): return Expression.from_cexpr(x.cg_version, c_sparsemax(x.c()))
cpdef Expression softsign(Expression x): return Expression.from_cexpr(x.cg_version, c_softsign(x.c()))
cpdef Expression pow(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_pow(x.c(), y.c()))
cpdef Expression bmin(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_bmin(x.c(), y.c()))
cpdef Expression bmax(Expression x, Expression y): ensure_freshness(y); return Expression.from_cexpr(x.cg_version, c_bmax(x.c(), y.c()))
cpdef Expression transpose(Expression x): return Expression.from_cexpr(x.cg_version, c_transpose(x.c()))
Expand Down
7 changes: 7 additions & 0 deletions python/dynet_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,17 @@ def filter1d_narrow(x, y):
def tanh(x): return GVExpr('tanh', [x], copy_dim(x))
def exp(x): return GVExpr('exp', [x], copy_dim(x))
def square(x): return GVExpr('square', [x], copy_dim(x))
def sqrt(x): return GVExpr('sqrt', [x], copy_dim(x))
def erf(x): return GVExpr('erf', [x], copy_dim(x))
def cube(x): return GVExpr('cube', [x], copy_dim(x))
def log(x): return GVExpr('log', [x], copy_dim(x))
def lgamma(x): return GVExpr('lgamma', [x], copy_dim(x))
def logistic(x): return GVExpr('logistic', [x], copy_dim(x))
def rectify(x): return GVExpr('rectify', [x], copy_dim(x))
def log_softmax(x, restrict=None): return GVExpr('log_softmax', [x,restrict], copy_dim(x))
def softmax(x): return GVExpr('softmax', [x], copy_dim(x))
def softsign(x): return GVExpr('softsign', [x], copy_dim(x))
def pow(x, y): return GVExpr('pow', [x,y], ensure_same_dim(x,y))
def bmin(x, y): return GVExpr('bmin', [x,y], ensure_same_dim(x,y))
def bmax(x, y): return GVExpr('bmax', [x,y], ensure_same_dim(x,y))
def transpose(x): return GVExpr('transpose', [x], x.dim[::-1] if x.dim.isvalid() else InvalidDim)
Expand Down Expand Up @@ -690,6 +694,9 @@ def set_clip_threshold(self, thr): pass
def get_clip_threshold(self): pass

class SimpleSGDTrainer(Trainer):
"""
This object is very cool!
"""
def __init__(self, m, e0 = 0.1): pass
class MomentumSGDTrainer(Trainer):
def __init__(self, m, e0 = 0.01, mom = 0.9): pass
Expand Down