Segmentation violation detected in Matlab2016a on Ubuntu15.10 - linux
I get this error when starting Matlab2016a on Ubuntu 15.10 64bit. How can I fix it?
MATLAB crash file:/home/jalal/matlab_crash_dump.8510-1:
------------------------------------------------------------------------
Segmentation violation detected at Wed Aug 31 20:50:17 2016
------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled
Crash Mode : continue (default)
Current Graphics Driver: Unknown hardware
Current Visual : 0x21 (class 4, depth 24)
Default Encoding : UTF-8
GNU C Library : 2.21 stable
Host Name : klein
MATLAB Architecture : glnxa64
MATLAB Root : /usr/local/MATLAB/R2016a
MATLAB Version : 9.0.0.341360 (R2016a)
OpenGL : hardware
Operating System : Linux 4.2.0-42-generic #49-Ubuntu SMP Tue Jun 28 21:26:26 UTC 2016 x86_64
Processor ID : x86 Family 6 Model 63 Stepping 2, GenuineIntel
Virtual Machine : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : The X.Org Foundation (11702000), display :0
Fault Count: 1
Abnormal termination:
Segmentation violation
Register State (from fault):
RAX = 0000000000000000 RBX = 00007f7a44573808
RCX = 0000000000000000 RDX = 0000000000000003
RSP = 00007f7b3bdf3cd0 RBP = 00007f7b3bdf3df0
RSI = 0000000000000000 RDI = 00007f7a4456f9e8
R8 = 0000000000000018 R9 = 0000000000000000
R10 = 00007f7a4456f000 R11 = 00007f7a44574450
R12 = 00007f7a4478ff80 R13 = 0000000000000006
R14 = 00007f7a44570cc0 R15 = 00007f7aa82b4a60
RIP = 00007f7b5ce778ca EFL = 0000000000010206
CS = 0033 FS = 0000 GS = 0000
Stack Trace (from fault):
[ 0] 0x00007f7b5ce778ca /lib64/ld-linux-x86-64.so.2+00051402
[ 1] 0x00007f7b5ce804c1 /lib64/ld-linux-x86-64.so.2+00087233
[ 2] 0x00007f7b5ce7b474 /lib64/ld-linux-x86-64.so.2+00066676
[ 3] 0x00007f7b5ce7f9b3 /lib64/ld-linux-x86-64.so.2+00084403
[ 4] 0x00007f7b5a528fc9 /lib/x86_64-linux-gnu/libdl.so.2+00004041
[ 5] 0x00007f7b5ce7b474 /lib64/ld-linux-x86-64.so.2+00066676
[ 6] 0x00007f7b5a52962d /lib/x86_64-linux-gnu/libdl.so.2+00005677
[ 7] 0x00007f7b5a529061 /lib/x86_64-linux-gnu/libdl.so.2+00004193 dlopen+00000049
[ 8] 0x00007f7b56d740b6 /usr/local/MATLAB/R2016a/bin/glnxa64/libut.so+00315574
[ 9] 0x00007f7b56d74c76 /usr/local/MATLAB/R2016a/bin/glnxa64/libut.so+00318582 _Z11utGetModuleRKSbIDsSt11char_traitsIDsESaIDsEEPi+00000022
[ 10] 0x00007f7b56d74d6b /usr/local/MATLAB/R2016a/bin/glnxa64/libut.so+00318827 utGetModule+00000171
[ 11] 0x00007f7b4a1f9d45 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_dispatcher.so+00482629
[ 12] 0x00007f7b4a1eceaf /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_dispatcher.so+00429743 _ZN13Mlm_MATLAB_fn8try_loadEv+00000031
[ 13] 0x00007f7b4a1e3e95 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_dispatcher.so+00392853 _ZN13Mlm_MATLAB_fn4loadEv+00000037
[ 14] 0x00007f7b4a1e15e9 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_dispatcher.so+00382441 _ZN13Mfh_MATLAB_fn11dispatch_fhEiPP11mxArray_tagiS2_+00000057
[ 15] 0x00007f7b472261c9 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+09232841
[ 16] 0x00007f7b47352dbf /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+10464703
[ 17] 0x00007f7b47348a5a /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+10422874
[ 18] 0x00007f7b47311911 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+10197265
[ 19] 0x00007f7b46ddfb2a /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+04750122
[ 20] 0x00007f7b46de0a4c /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+04753996
[ 21] 0x00007f7b46ddeebc /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+04746940
[ 22] 0x00007f7b46ddc9ea /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+04737514
[ 23] 0x00007f7b46ddcdb1 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+04738481
[ 24] 0x00007f7b46ddea63 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+04745827
[ 25] 0x00007f7b46ddebe9 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+04746217
[ 26] 0x00007f7b46e8f16f /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+05468527
[ 27] 0x00007f7b46e9222a /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+05481002
[ 28] 0x00007f7b47134543 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+08242499
[ 29] 0x00007f7b470fd07e /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+08015998
[ 30] 0x00007f7b47101058 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+08032344
[ 31] 0x00007f7b47101107 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+08032519
[ 32] 0x00007f7b4717732c /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+08516396
[ 33] 0x00007f7b4717770c /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_lxe.so+08517388
[ 34] 0x00007f7b49bfad7d /usr/local/MATLAB/R2016a/bin/glnxa64/libmwm_interpreter.so+03165565 _Z51inEvalCmdWithLocalReturnInDesiredWSAndPublishEventsRKSbIDsSt11char_traitsIDsESaIDsEEPibbP15inWorkSpace_tag+00000077
[ 35] 0x00007f7b4a8739e1 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00825825 _ZNK3iqm18InternalEvalPlugin24inEvalCmdWithLocalReturnERKSbIDsSt11char_traitsIDsESaIDsEEP15inWorkSpace_tag+00000081
[ 36] 0x00007f7b4a873b58 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00826200 _ZN3iqm18InternalEvalPlugin7executeEP15inWorkSpace_tagRN5boost10shared_ptrIN14cmddistributor17IIPCompletedEventEEE+00000120
[ 37] 0x00007f7afe767ee4 /usr/local/MATLAB/R2016a/bin/glnxa64/libnativejmi.so+00974564 _ZN9nativejmi21JmiInternalEvalPlugin7executeEP15inWorkSpace_tagRN5boost10shared_ptrIN14cmddistributor17IIPCompletedEventEEE+00000340
[ 38] 0x00007f7afe78dedd /usr/local/MATLAB/R2016a/bin/glnxa64/libnativejmi.so+01130205 _ZN3mcr3mvm27McrSwappingIqmPluginAdapterIN9nativejmi21JmiInternalEvalPluginEE7executeEP15inWorkSpace_tagRN5boost10shared_ptrIN14cmddistributor17IIPCompletedEventEEE+00000429
[ 39] 0x00007f7b4a866f98 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00774040
[ 40] 0x00007f7b4a850c87 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00683143
[ 41] 0x00007f7b496c87a9 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwbridge.so+00173993
[ 42] 0x00007f7b496c8c44 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwbridge.so+00175172
[ 43] 0x00007f7b496cf1a5 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwbridge.so+00201125
[ 44] 0x00007f7b496cf2ac /usr/local/MATLAB/R2016a/bin/glnxa64/libmwbridge.so+00201388
[ 45] 0x00007f7b496cf97b /usr/local/MATLAB/R2016a/bin/glnxa64/libmwbridge.so+00203131 _Z8mnParserv+00000715
[ 46] 0x00007f7b4a523c13 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00695315
[ 47] 0x00007f7b5c80d81c /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmvm.so+02410524 _ZNK5boost9function0IvEclEv+00000028
[ 48] 0x00007f7b4a525925 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00702757
[ 49] 0x00007f7b4a526839 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00706617 _ZN5boost6detail17task_shared_stateINS_3_bi6bind_tIvPFvRKNS_8functionIFvvEEEENS2_5list1INS2_5valueIS6_EEEEEEvE6do_runEv+00000025
[ 50] 0x00007f7b572ee8a0 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwms.so+03168416 _ZN5boost6detail22task_base_shared_stateIvE3runEv+00000064
[ 51] 0x00007f7b4a527717 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00710423
[ 52] 0x00007f7b4a52375a /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00694106
[ 53] 0x00007f7b4a896c06 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00969734
[ 54] 0x00007f7b4a884b4c /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00895820 _ZN5boost6detail8function21function_obj_invoker0ISt8functionIFNS_3anyEvEES4_E6invokeERNS1_15function_bufferE+00000028
[ 55] 0x00007f7b4a88521f /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00897567 _ZNK5boost9function0INS_3anyEEclEv+00000031
[ 56] 0x00007f7b4a884993 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00895379 _ZN3iqm18PackagedTaskPlugin7executeEP15inWorkSpace_tagRN5boost10shared_ptrIN14cmddistributor17IIPCompletedEventEEE+00000163
[ 57] 0x00007f7b4a53871d /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00780061
[ 58] 0x00007f7b4a866f98 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00774040
[ 59] 0x00007f7b4a8515af /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00685487
[ 60] 0x00007f7b4a84e7e3 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwiqm.so+00673763
[ 61] 0x00007f7b5c1caa3a /usr/local/MATLAB/R2016a/bin/glnxa64/libmwservices.so+03443258
[ 62] 0x00007f7b5c1c98a7 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwservices.so+03438759
[ 63] 0x00007f7b5c1ca10c /usr/local/MATLAB/R2016a/bin/glnxa64/libmwservices.so+03440908 _Z25svWS_ProcessPendingEventsiib+00000092
[ 64] 0x00007f7b4a523ed2 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00696018
[ 65] 0x00007f7b4a524211 /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00696849
[ 66] 0x00007f7b4a510cfd /usr/local/MATLAB/R2016a/bin/glnxa64/libmwmcr.so+00617725
[ 67] 0x00007f7b5acff6aa /lib/x86_64-linux-gnu/libpthread.so.0+00030378
[ 68] 0x00007f7b5aa3513d /lib/x86_64-linux-gnu/libc.so.6+01077565 clone+00000109
[ 69] 0x0000000000000000 <unknown-module>+00000000
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help.
Solved the problem this way using the instructions in MathWorks bug reports:
jalal#klein:~$ cd /usr/local/MATLAB/R2016a/
jalal#klein:/usr/local/MATLAB/R2016a$ cd sys/os/glnxa64/
jalal#klein:/usr/local/MATLAB/R2016a/sys/os/glnxa64$ sudo mv libstdc++.so.6 libstdc++.so.6.old
[sudo] password for jalal:
jalal#klein:/usr/local/MATLAB/R2016a/sys/os/glnxa64$ matlab
After installing matlab-support
I have to run sudo matlab -nodisplay
Related
Point-convolution in PyTorch
I would like to implement a point-convolution to my input tensor. Let's say we have: input_ = torch.randn(1,1,8,1) input_.shape Out[70]: torch.Size([1, 1, 8, 1]) input_ Out[71]: tensor([[[[ 0.7656], [-0.3400], [-0.2487], [ 0.6246], [ 2.0450], [-0.9588], [ 1.2221], [-1.3164]]]]) where the dimensions represent respectively (batch_size, n_channels, height, width). Then, (keeping fixed batch_size and channel), I would like to apply to each a nn.Conv1d layer basically to expand the number of channels. What I've tried has been: list(torch.unbind(input_,dim=2)) Out[72]: [tensor([[[0.7656]]]), tensor([[[-0.3400]]]), tensor([[[-0.2487]]]), tensor([[[0.6246]]]), tensor([[[2.0450]]]), tensor([[[-0.9588]]]), tensor([[[1.2221]]]), tensor([[[-1.3164]]])] and then applying nn.Conv1d entrywise to these elements? Would that be a correct way? EDIT: Should I use nn.Conv1d directly on my original input_ by doing conv = nn.Conv1d(in_channels=1, out_channels=3, kernel_size=(1,1) conv(input_) conv(input_) Out[89]: tensor([[[[-0.1481], [ 1.5345], [ 0.3082], [ 1.8677], [ 0.7515], [ 1.2916], [ 0.0218], [ 0.5606]], [[-1.2975], [-0.3080], [-1.0292], [-0.1121], [-0.7685], [-0.4509], [-1.1976], [-0.8808]], [[-0.7169], [ 0.6493], [-0.3464], [ 0.9199], [ 0.0135], [ 0.4521], [-0.5790], [-0.1415]]]], grad_fn=<ThnnConv2DBackward0>) conv(input_).shape Out[90]: torch.Size([1, 3, 8, 1]) I'm not sure though if doing this is the same as my original purpose.
Cabal - Installing beam-migrate
I'm trying to install beam-migrate dependency and it fails with the following error: Configuring library for beam-migrate-0.5.0.0.. Preprocessing library for beam-migrate-0.5.0.0.. Building library for beam-migrate-0.5.0.0.. [ 1 of 20] Compiling Database.Beam.Migrate.SQL.SQL92 ( Database/Beam/Migrate/SQL/SQL92.hs, dist/build/Database/Beam/Migrate/SQL/SQL92.o ) [ 2 of 20] Compiling Database.Beam.Migrate.Types.Predicates ( Database/Beam/Migrate/Types/Predicates.hs, dist/build/Database/Beam/Migrate/Types/Predicates.o ) [ 3 of 20] Compiling Database.Beam.Migrate.SQL.Types ( Database/Beam/Migrate/SQL/Types.hs, dist/build/Database/Beam/Migrate/SQL/Types.o ) [ 4 of 20] Compiling Database.Beam.Migrate.Serialization ( Database/Beam/Migrate/Serialization.hs, dist/build/Database/Beam/Migrate/Serialization.o ) [ 5 of 20] Compiling Database.Beam.Migrate.Checks ( Database/Beam/Migrate/Checks.hs, dist/build/Database/Beam/Migrate/Checks.o ) [ 6 of 20] Compiling Database.Beam.Migrate.Generics.Tables ( Database/Beam/Migrate/Generics/Tables.hs, dist/build/Database/Beam/Migrate/Generics/Tables.o ) [ 7 of 20] Compiling Database.Beam.Migrate.Types.CheckedEntities ( Database/Beam/Migrate/Types/CheckedEntities.hs, dist/build/Database/Beam/Migrate/Types/CheckedEntities.o ) [ 8 of 20] Compiling Database.Beam.Migrate.Types ( Database/Beam/Migrate/Types.hs, dist/build/Database/Beam/Migrate/Types.o ) [ 9 of 20] Compiling Database.Beam.Migrate.SQL.Tables ( Database/Beam/Migrate/SQL/Tables.hs, dist/build/Database/Beam/Migrate/SQL/Tables.o ) Database/Beam/Migrate/SQL/Tables.hs:32:5: warning: [-Wdodgy-exports] The export item ‘IsNotNull(..)’ suggests that ‘IsNotNull’ has (in-scope) constructors or class methods, but it has none | 32 | , IsNotNull(..) | ^^^^^^^^^^^^^ [10 of 20] Compiling Database.Beam.Migrate.SQL.BeamExtensions ( Database/Beam/Migrate/SQL/BeamExtensions.hs, dist/build/Database/Beam/Migrate/SQL/BeamExtensions.o ) [11 of 20] Compiling Database.Beam.Migrate.SQL ( Database/Beam/Migrate/SQL.hs, dist/build/Database/Beam/Migrate/SQL.o ) [12 of 20] Compiling Database.Beam.Migrate.SQL.Builder ( Database/Beam/Migrate/SQL/Builder.hs, dist/build/Database/Beam/Migrate/SQL/Builder.o ) [13 of 20] Compiling Database.Beam.Migrate.Generics.Types ( Database/Beam/Migrate/Generics/Types.hs, dist/build/Database/Beam/Migrate/Generics/Types.o ) [14 of 20] Compiling Database.Beam.Migrate.Generics ( Database/Beam/Migrate/Generics.hs, dist/build/Database/Beam/Migrate/Generics.o ) [15 of 20] Compiling Database.Beam.Haskell.Syntax ( Database/Beam/Haskell/Syntax.hs, dist/build/Database/Beam/Haskell/Syntax.o ) Database/Beam/Haskell/Syntax.hs:1041:10: error: Duplicate instance declarations: instance Hashable a => Hashable (S.Set a) -- Defined at Database/Beam/Haskell/Syntax.hs:1041:10 instance Hashable v => Hashable (S.Set v) -- Defined in ‘hashable-1.3.5.0:Data.Hashable.Class’ | 1041 | instance Hashable a => Hashable (S.Set a) where | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cabal: Failed to build beam-migrate-0.5.0.0
beam-migrate-0.5.0.0 is incompatible with hashable-1.3.5.0. Either upgrade to beam-migrate-0.5.1.0 (preferred), or downgrade to hashable-1.3.3.0.
show coordinates of an image stored in an array using mathplotlib
from nptdms import TdmsFile as td from matplotlib import pyplot as plt import numpy as np import skimage.color import skimage.filters import mplcursors from skimage.feature import corner_harris,corner_peaks file = 'sample.tdms' with td.open(file) as tdms_file: img = tdms_file.as_dataframe() cropped_list = [] sel=cropped_list.append(img.iloc[700:1250,450:1550:]) coords=corner_peaks(corner_harris(sel),min_distance=10,threshold_rel=0.02) fig, ax = plt.subplots() ax.imshow(sel, cmap='gray') plotted_points =ax.plot(coords[:, 1], coords[:, 0], color='cyan', marker='o',linestyle='None', markersize=2) mplcursors.cursor(plotted_points, hover=True) plt.show( I tried using mplcursors. But nothing is shown on plot when mouse is hovered. The arrow is not showing any coordinates. I tried by just plotting points without image, still its not showing any coordinates. [106 190] [205 167] 249 280] [ 80 301] [343 294] [207 151] [293 300] [ 30 298] [116 301] [290 261] [ 38 81] [295 316] [209 262] [210 285] [205 323] [282 244] [128 158] [255 26] [133 708] [213 243] [214 690] [ 62 241] [ 68 181] [254 692] [ 35 21] [ 74 318] [290 275] [284 178] [185 21] [207 107] [ 25 323] [331 88] [113 273] [157 293] [112 241] [164 323] [250 301] [137 20] [ 35 645] [284 484] [244 317] [ 27 26 9] [356 331] [356 25] [131 279] [206 296] [ 35 490] [139 85] [215 396] [116 150] [139 644] [338 305] [183 330] [140 488] [327 331] [357 550] [187 707] [260 705] [180 646] [282 552] [ 61 554] [113 485] [163 269] [114 642] [287 645] [281 287] [140 241] [327 181] [ 36 552] [242 263] [257 87] [ 52 18] [358 61] [110 397] [359 692] [139 176] [212 23] [140 332] [271 704] [254 359] [ 63 19] [ 37 396] [110 20] [ 65 82] [ 36 176] [211 706] [108 162] [ 65 397] [212 552] [ 62 645] [109 550] [256 240] [283 24] [185 552] [286 86] [186 242] [355 180] [141 550] [ 64 707] [283 704] [285 330] [257 398] [185 398] [285 398] [109 126] [356 89] [ 37 709] [ 64 331] [111 316] [ 35 334] [214 487] [328 241] [119 172] [212 88] [356 244] [253 332] [ 39 240] [328 27] [359 395] [ 77 266] [358 641] [211 642] [110 706] [181 151] [140 396] [110 332] [ 64 489] [182 486] [328 396] [254 485] [195 274] [256 549] [111 83] [328 639] [253 179] [339 270] [206 135] [325 488]] this is the coords array. So how can I save the coordiantes in a variable according to shape of image. Only rectangles in first row. My image is a series of rectangle shaped sensors. Thats why i tried to find the coordinates by mouse click.
mplcursors automatically create annotations with the x and y positions. Only when you need extra information, you'd need to write a function to change the annotation depending on the selected point. Here is some code, using a random image to show how it would work: import matplotlib.pyplot as plt import numpy as np import mplcursors coords = np.array([[301,557],[301,378],[201,426],[77,58],[243,12],[466,87],[161,75],[302,489],[197,507],[157,400],[131,85],[379,253],[386,525],[215,500],[165,963],[210,381],[308,254],[285,378],[217,628],[77,500],[156,629],[527,67],[514,1010],[234,264],[523,717],[282,630],[523,799],[355,783],[379,474],[353,711],[351,473],[416,719],[232,249],[185,75],[451,409],[130,247],[384,509],[309,473],[202,937],[130,561],[340,549],[310,627],[348,256],[381,869],[258,555],[342,417],[204,393],[385,489],[523,483],[303,784],[448,476],[228,939],[229,559],[454,260],[158,939],[109,521],[158,248],[160,561],[425,319],[129,939],[526,263],[221,389],[236,754],[203,628],[335,492],[453,319],[160,313],[197,76],[420,410],[129,874],[279,250],[130,310],[206,472],[352,1017],[228,508],[117,555],[278,783],[306,937],[424,475],[157,874],[235,407],[78,552],[129,625],[128,781],[423,934],[349,316],[202,781],[378,935],[475,543],[204,547],[391,546],[424,253],[202,251],[170,549],[236,781],[132,471],[75,959],[128,407],[200,356],[309,716],[232,715],[422,629],[274,562],[201,563],[234,471],[149,89],[277,713],[290,12],[236,313],[161,720],[383,626],[350,867],[451,782],[379,783],[450,934],[166,467],[347,626],[450,559],[451,712],[418,875],[379,318],[156,1018],[306,871],[379,408],[278,471],[203,715],[161,782],[203,872],[277,936],[234,874],[348,933],[235,627],[420,561],[438,502],[204,314],[263,499],[279,317],[421,780],[453,627],[334,959],[174,496],[125,500],[131,542],[159,545],[352,499],[79,1012],[417,501],[501,128],[295,340],[215,543],[218,358],[168,1020],[112,504],[158,502]]) fig, ax = plt.subplots() img = np.random.rand(550, 1050) ax.imshow(img, cmap='gray') plotted_points = ax.plot(coords[:, 1], coords[:, 0], color='cyan', marker='o', linestyle='None', markersize=2) mplcursors.cursor(plotted_points, hover=True) plt.show()
How to optimize following code with minimum use of for loop?
Code is taking too much time for computation and I want to reduce number of iterations. I tried to use method suggested by #Albuquerque How to optimise the following for loop code?, but for this code I have 3d array. Please suggest how to optimize following code. K=2 D=3 N=3 sigma=np.asarray([[1,2,3],[4,5,6]]) F=np.asarray([[1,2,3],[4,5,6]]) X=np.asarray([[1,2,3],[4,5,6],[7,8,9]]) W= [ [ [1,2,3], [3,2,1] ], [ [1,1,19], [1,2,1] ], [ [2,2,2], [1,3,5] ] ] result2= np.ones([N, D]) for i in range(N): for l in range(D): result2[i][l]=np.sum(W[i][k][l]*(F[k][l]+sigma[k][l]*X[i][l]) for k in range(K)) output- array([[ 26., 42., 60.], [ 25., 72., 441.], [ 48., 171., 360.]])
pytorch how to select channels by mask?
I want to know how do I select channels by the mask in Pytorch. [channel1 channel2 channel3 channel4] x [1,0,0,1] --> [channel1,channel4] I tried torch.masked_select() and it did't work. if the input has a shape like [B,C,H,W] the output's shape should be [B,masked_C,H,W], import torch from torch import nn input = torch.randn((1,5,3,3)) pool = nn.AdaptiveAvgPool2d(1) w = torch.sigmoid(pool(input)).view(1,-1) mask = torch.gt(w,0.5) print(input) print(w) print(mask) the output is as following: tensor([[[[ 0.9129, -0.9763, 1.4460], [ 0.3608, 0.5561, -1.4612], [ 1.4953, -1.2474, 0.4069]], [[-0.9121, 0.1261, 0.4661], [-1.1624, -1.0266, -1.5419], [ 1.0644, 1.0039, -0.4022]], [[-1.8454, -0.2150, 2.3703], [ 0.5224, 0.3366, 1.7545], [-0.4624, 1.2639, 1.8032]], [[-1.1558, -1.9985, -1.1336], [-0.4400, -0.2092, 0.0677], [-0.4172, -0.3614, -1.3193]], [[-0.9441, -0.2944, 0.3381], [ 1.6562, -0.5623, 0.0599], [ 0.7229, 0.0472, -0.5122]]]]) tensor([[0.5414, 0.4341, 0.6489, 0.3156, 0.5142]]) tensor([[1, 0, 1, 0, 1]], dtype=torch.uint8) the result I want is like this: tensor([[[[ 0.9129, -0.9763, 1.4460], [ 0.3608, 0.5561, -1.4612], [ 1.4953, -1.2474, 0.4069]], [[-1.8454, -0.2150, 2.3703], [ 0.5224, 0.3366, 1.7545], [-0.4624, 1.2639, 1.8032]], [[-0.9441, -0.2944, 0.3381], [ 1.6562, -0.5623, 0.0599], [ 0.7229, 0.0472, -0.5122]]]])
I believe you can simply do: input[mask] Btw. you don't need to call sigmoid and then .gt(0.5). You can directly do .gt(0.0) without calling the sigmoid.