You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/31 16:26:13 UTC
[GitHub] justanotheruser opened a new issue #11111: Custom linear regression
diverges on simplest example, but built-in LinearRegression does not
justanotheruser opened a new issue #11111: Custom linear regression diverges on simplest example, but built-in LinearRegression does not
URL: https://github.com/apache/incubator-mxnet/issues/11111
I'm trying to implement some custom loss layer, but I found that I can't make work even simplest custom linear regression layer with simplest model. I want to make conv net with one layer that accepts RGB image (entirely blue, green or red) and outputs it.
This is my custom operator code:
```
class Colors(mx.operator.CustomOp):
def forward(self, is_train, req, in_data, out_data, aux):
self.assign(out_data[0], req[0], in_data[0])
def backward(self, req, out_grad, in_data, out_data, in_grad, aux):
delta_mx = in_data[1] - out_data[0]
self.assign(in_grad[0], req[0], delta_mx)
@mx.operator.register("colors")
class ColorsProp(mx.operator.CustomOpProp):
def __init__(self, width, height):
super(ColorsProp, self).__init__(need_top_grad=False)
self.width = int(width)
self.height = int(height)
def list_arguments(self):
return ['data', 'color']
def list_outputs(self):
return ['output']
def infer_shape(self, in_shape):
output_shape = (in_shape[0][0], 3, self.width, self.height)
return in_shape, [output_shape], []
def create_operator(self, ctx, shapes, dtypes):
return Colors()
```
This is my model:
```
sym = mx.sym.Variable('data')
sym = mx.sym.Convolution(sym, kernel=(1, 1), stride=(1, 1), num_filter=3)
_, _, width, height = sym.infer_shape(data=yolo_settings.input_shape)[1][0]
sym = mx.symbol.Custom(data=sym, name='colors', op_type='colors', width=width, height=height)
#lbl = mx.sym.Variable('colors_color')
#sym = mx.sym.LinearRegressionOutput(sym, label=lbl)
```
When I replace last line with commented out lines, SGD converges. With custom loss output of conv layer becomes hugely negative VERY fast, and after a few iterations it becomes full of nan's. What am I doing wrong?
My environment:
----------Python Info----------
Version : 3.6.3
Compiler : GCC 5.4.0 20160609
Build : ('default', 'Oct 6 2017 08:44:35')
Arch : ('64bit', 'ELF')
------------Pip Info-----------
Version : 10.0.1
Directory : /home/d-sleptsov/.local/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Version : 1.2.0
Directory : /home/d-sleptsov/3rdParty/incubator-mxnet/python/mxnet
Hashtag not found. Not installed from pre-built package.
----------System Info----------
Platform : Linux-4.13.0-43-generic-x86_64-with-Ubuntu-16.04-xenial
system : Linux
node : d-sleptsov
release : 4.13.0-43-generic
version : #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018
----------Hardware Info----------
machine : x86_64
processor : x86_64
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 94
Model name: Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
Stepping: 3
CPU MHz: 800.052
CPU max MHz: 3300.0000
CPU min MHz: 800.0000
BogoMIPS: 5424.00
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 6144K
NUMA node0 CPU(s): 0-3
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti retpoline intel_pt rsb_ctxsw spec_ctrl tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services