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

Commit

Permalink
cast scalar value in invoke to float (#8778)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjolivier01 authored and piiswrong committed Nov 22, 2017
1 parent be18794 commit a0031ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/mxnet/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,9 @@ def update(self, index, weight, grad, state):
srt = op.sqrt(adjusted_add)
div = _internal._scatter_elemwise_div(grad, srt)
retained_weight = sparse.retain(weight, grad.indices)
to_add = sparse.elemwise_add(div, _internal._mul_scalar(retained_weight, wd))
to_add = sparse.elemwise_add(div, _internal._mul_scalar(retained_weight, float(wd)))
assert len(to_add.indices) == grad_indices_count
weight[:] = sparse.elemwise_add(weight, _internal._mul_scalar(to_add, -lr))
weight[:] = sparse.elemwise_add(weight, _internal._mul_scalar(to_add, float(-lr)))
state[:] = history
assert state.stype == save_history_stype
assert len(history_indices) == grad_indices_count
Expand Down
2 changes: 1 addition & 1 deletion python/mxnet/symbol/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,7 @@ def full(shape, val, dtype=None, **kwargs):
"""
if dtype is None:
dtype = _numpy.float32
return _internal._full(shape=shape, dtype=dtype, value=val, **kwargs)
return _internal._full(shape=shape, dtype=dtype, value=float(val), **kwargs)

# pylint: disable=redefined-outer-name
def arange(start, stop=None, step=1.0, repeat=1, name=None, dtype=None):
Expand Down

0 comments on commit a0031ac

Please sign in to comment.