| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827 |
- [
- {
- "name": "Activation",
- "module": "keras.layers",
- "category": "Activation",
- "description": "Applies an activation function to an output.",
- "attributes": [
- {
- "description": "Activation function. It could be a callable, or the name of\n an activation from the `keras.activations` namespace.",
- "name": "activation"
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments, such as `name` and `dtype`."
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the batch axis)\nwhen using this layer as the first layer in a model.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as input.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> layer = keras.layers.Activation('relu')\n>>> layer(np.array([-3.0, -1.0, 0.0, 2.0]))\n[0.0, 0.0, 0.0, 2.0]\n>>> layer = keras.layers.Activation(keras.activations.relu)\n>>> layer(np.array([-3.0, -1.0, 0.0, 2.0]))\n[0.0, 0.0, 0.0, 2.0]"
- }
- ]
- },
- {
- "name": "ActivityRegularization",
- "module": "keras.layers",
- "description": "Layer that applies an update to the cost function based input activity.",
- "attributes": [
- {
- "description": "L1 regularization factor (positive float).",
- "name": "l1"
- },
- {
- "description": "L2 regularization factor (positive float).",
- "name": "l2"
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the samples axis)\nwhen using this layer as the first layer in a model.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as input.",
- "name": "output"
- }
- ]
- },
- {
- "name": "Add",
- "module": "keras.layers",
- "description": "Performs elementwise addition operation.\n\nIt takes as input a list of tensors, all of the same shape,\nand returns a single tensor (also of the same shape).",
- "inputs": [
- {
- "name": "inputs",
- "list": true
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 3, 4)\n>>> x1 = np.random.rand(*input_shape)\n>>> x2 = np.random.rand(*input_shape)\n>>> y = keras.layers.Add()([x1, x2])"
- },
- {
- "summary": "Usage in a Keras model:",
- "code": ">>> input1 = keras.layers.Input(shape=(16,))\n>>> x1 = keras.layers.Dense(8, activation='relu')(input1)\n>>> input2 = keras.layers.Input(shape=(32,))\n>>> x2 = keras.layers.Dense(8, activation='relu')(input2)\n>>> # equivalent to `added = keras.layers.add([x1, x2])`\n>>> added = keras.layers.Add()([x1, x2])\n>>> out = keras.layers.Dense(4)(added)\n>>> model = keras.models.Model(inputs=[input1, input2], outputs=out)"
- }
- ]
- },
- {
- "name": "Attention",
- "module": "keras.layers",
- "category": "Attention",
- "description": "Dot-product attention layer, a.k.a. Luong-style attention.\n\nInputs are a list with 2 or 3 elements:\n1. A `query` tensor of shape `(batch_size, Tq, dim)`.\n2. A `value` tensor of shape `(batch_size, Tv, dim)`.\n3. A optional `key` tensor of shape `(batch_size, Tv, dim)`. If none\n supplied, `value` will be used as a `key`.\n\nThe calculation follows the steps:\n1. Calculate attention scores using `query` and `key` with shape\n `(batch_size, Tq, Tv)`.\n2. Use scores to calculate a softmax distribution with shape\n `(batch_size, Tq, Tv)`.\n3. Use the softmax distribution to create a linear combination of `value`\n with shape `(batch_size, Tq, dim)`.",
- "attributes": [
- {
- "description": "If `True`, will create a scalar variable to scale the\n attention scores.",
- "name": "use_scale"
- },
- {
- "description": "Boolean. Set to `True` for decoder self-attention. Adds a mask\n such that position `i` cannot attend to positions `j > i`. This prevents\n the flow of information from the future towards the past. Defaults to\n `False`.",
- "name": "causal"
- },
- {
- "description": "Float between 0 and 1. Fraction of the units to drop for the\n attention scores. Defaults to `0.0`.",
- "name": "dropout"
- },
- {
- "description": "List of the following tensors:\n - `query`: Query tensor of shape `(batch_size, Tq, dim)`.\n - `value`: Value tensor of shape `(batch_size, Tv, dim)`.\n - `key`: Optional key tensor of shape `(batch_size, Tv, dim)`. If\n not given, will use `value` for both `key` and `value`, which is\n the most common case.",
- "name": "inputs"
- },
- {
- "description": "List of the following tensors:\n - `query_mask`: A boolean mask tensor of shape `(batch_size, Tq)`.\n If given, the output will be zero at the positions where\n `mask==False`.\n - `value_mask`: A boolean mask tensor of shape `(batch_size, Tv)`.\n If given, will apply the mask such that values at positions\n where `mask==False` do not contribute to the result.",
- "name": "mask"
- },
- {
- "description": "bool, it `True`, returns the attention scores\n (after masking and softmax) as an additional output argument.",
- "name": "return_attention_scores"
- },
- {
- "description": "Python boolean indicating whether the layer should behave in\n training mode (adding dropout) or in inference mode (no dropout).",
- "name": "training"
- },
- {
- "name": "score_mode",
- "description": "Function to use to compute attention scores, one of\n `{\"dot\", \"concat\"}`. `\"dot\"` refers to the dot product between the\n query and key vectors. `\"concat\"` refers to the hyperbolic tangent\n of the concatenation of the `query` and `key` vectors."
- },
- {
- "name": "use_causal_mask",
- "description": "Boolean. Set to `True` for decoder self-attention. Adds\n a mask such that position `i` cannot attend to positions `j > i`.\n This prevents the flow of information from the future towards the\n past. Defaults to `False`.\n\nOutput:\n Attention outputs of shape `(batch_size, Tq, dim)`.\n (Optional) Attention scores after masking and softmax with shape\n `(batch_size, Tq, Tv)`."
- },
- {
- "name": "seed",
- "description": "A Python integer to use as random seed in case of `dropout`."
- }
- ],
- "inputs": [
- {
- "name": "query",
- "type": "Tensor[]"
- },
- {
- "name": "value",
- "type": "Tensor[]"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "Average",
- "module": "keras.layers",
- "category": "Tensor",
- "description": "Averages a list of inputs element-wise..\n\nIt takes as input a list of tensors, all of the same shape,\nand returns a single tensor (also of the same shape).",
- "inputs": [
- {
- "name": "inputs",
- "list": true
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 3, 4)\n>>> x1 = np.random.rand(*input_shape)\n>>> x2 = np.random.rand(*input_shape)\n>>> y = keras.layers.Average()([x1, x2])"
- },
- {
- "summary": "Usage in a Keras model:",
- "code": ">>> input1 = keras.layers.Input(shape=(16,))\n>>> x1 = keras.layers.Dense(8, activation='relu')(input1)\n>>> input2 = keras.layers.Input(shape=(32,))\n>>> x2 = keras.layers.Dense(8, activation='relu')(input2)\n>>> # equivalent to `y = keras.layers.average([x1, x2])`\n>>> y = keras.layers.Average()([x1, x2])\n>>> out = keras.layers.Dense(4)(y)\n>>> model = keras.models.Model(inputs=[input1, input2], outputs=out)"
- }
- ]
- },
- {
- "name": "AveragePooling1D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Average pooling for temporal data.\n\nDownsamples the input representation by taking the average value over the\nwindow defined by `pool_size`. The window is shifted by `strides`. The\nresulting output when using \"valid\" padding option has a shape of:\n`output_shape = (input_shape - pool_size + 1) / strides)`\n\nThe resulting output shape when using the \"same\" padding option is:\n`output_shape = input_shape / strides`",
- "attributes": [
- {
- "description": "int, size of the max pooling window.",
- "name": "pool_size"
- },
- {
- "description": "int or None. Specifies how much the pooling window moves\n for each pooling step. If None, it will default to `pool_size`.",
- "name": "strides"
- },
- {
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input such that output has the same\n height/width dimension as the input.",
- "name": "padding"
- },
- {
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, steps, features)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, steps)`. It defaults to the `image_data_format`\n value found in your Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 3D tensor with shape `(batch_size, steps, features)`.\n- If `data_format=\"channels_first\"`:\n 3D tensor with shape `(batch_size, features, steps)`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 3D tensor with shape `(batch_size, downsampled_steps, features)`.\n- If `data_format=\"channels_first\"`:\n 3D tensor with shape `(batch_size, features, downsampled_steps)`.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "summary": "`strides=1` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([1., 2., 3., 4., 5.])\n>>> x = np.reshape(x, [1, 5, 1])\n>>> avg_pool_1d = keras.layers.AveragePooling1D(pool_size=2,\n... strides=1, padding=\"valid\")\n>>> avg_pool_1d(x)"
- },
- {
- "summary": "`strides=2` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([1., 2., 3., 4., 5.])\n>>> x = np.reshape(x, [1, 5, 1])\n>>> avg_pool_1d = keras.layers.AveragePooling1D(pool_size=2,\n... strides=2, padding=\"valid\")\n>>> avg_pool_1d(x)"
- },
- {
- "summary": "`strides=1` and `padding=\"same\"`:",
- "code": ">>> x = np.array([1., 2., 3., 4., 5.])\n>>> x = np.reshape(x, [1, 5, 1])\n>>> avg_pool_1d = keras.layers.AveragePooling1D(pool_size=2,\n... strides=1, padding=\"same\")\n>>> avg_pool_1d(x)"
- }
- ]
- },
- {
- "name": "AveragePooling2D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Average pooling operation for 2D spatial data.\n\nDownsamples the input along its spatial dimensions (height and width)\nby taking the average value over an input window\n(of size defined by `pool_size`) for each channel of the input.\nThe window is shifted by `strides` along each dimension.\n\nThe resulting output when using the `\"valid\"` padding option has a spatial\nshape (number of rows or columns) of:\n`output_shape = math.floor((input_shape - pool_size) / strides) + 1`\n(when `input_shape >= pool_size`)\n\nThe resulting output shape when using the `\"same\"` padding option is:\n`output_shape = input_shape`",
- "attributes": [
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, channels, height, width)`. It defaults to the\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json`. If you never set it, then it will be\n `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "description": "int or tuple of 2 integers, factors by which to downscale\n (dim1, dim2). If only one integer is specified, the same\n window length will be used for all dimensions.",
- "name": "pool_size"
- },
- {
- "description": "int or tuple of 2 integers, or None. Strides values. If None,\n it will default to `pool_size`. If only one int is specified, the\n same stride size will be used for all dimensions.",
- "name": "strides"
- },
- {
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input such that output has the same\n height/width dimension as the input.",
- "name": "padding"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 4D tensor with shape `(batch_size, height, width, channels)`.\n- If `data_format=\"channels_first\"`:\n 4D tensor with shape `(batch_size, channels, height, width)`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 4D tensor with shape\n `(batch_size, pooled_height, pooled_width, channels)`.\n- If `data_format=\"channels_first\"`:\n 4D tensor with shape\n `(batch_size, channels, pooled_height, pooled_width)`.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "summary": "`strides=(1, 1)` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([[1., 2., 3.],\n... [4., 5., 6.],\n... [7., 8., 9.]])\n>>> x = np.reshape(x, [1, 3, 3, 1])\n>>> avg_pool_2d = keras.layers.AveragePooling2D(pool_size=(2, 2),\n... strides=(1, 1), padding=\"valid\")\n>>> avg_pool_2d(x)"
- },
- {
- "summary": "`strides=(2, 2)` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([[1., 2., 3., 4.],\n... [5., 6., 7., 8.],\n... [9., 10., 11., 12.]])\n>>> x = np.reshape(x, [1, 3, 4, 1])\n>>> avg_pool_2d = keras.layers.AveragePooling2D(pool_size=(2, 2),\n... strides=(2, 2), padding=\"valid\")\n>>> avg_pool_2d(x)"
- },
- {
- "summary": "`stride=(1, 1)` and `padding=\"same\"`:",
- "code": ">>> x = np.array([[1., 2., 3.],\n... [4., 5., 6.],\n... [7., 8., 9.]])\n>>> x = np.reshape(x, [1, 3, 3, 1])\n>>> avg_pool_2d = keras.layers.AveragePooling2D(pool_size=(2, 2),\n... strides=(1, 1), padding=\"same\")\n>>> avg_pool_2d(x)"
- }
- ]
- },
- {
- "name": "AveragePooling3D",
- "module": "keras.layers",
- "description": "Average pooling operation for 3D data (spatial or spatio-temporal).\n\nDownsamples the input along its spatial dimensions (depth, height, and\nwidth) by taking the average value over an input window (of size defined by\n`pool_size`) for each channel of the input. The window is shifted by\n`strides` along each dimension.",
- "attributes": [
- {
- "description": "int or tuple of 3 integers, factors by which to downscale\n (dim1, dim2, dim3). If only one integer is specified, the same\n window length will be used for all dimensions.",
- "name": "pool_size"
- },
- {
- "description": "int or tuple of 3 integers, or None. Strides values. If None,\n it will default to `pool_size`. If only one int is specified, the\n same stride size will be used for all dimensions.",
- "name": "strides"
- },
- {
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input such that output has the same\n height/width dimension as the input.",
- "name": "padding"
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape\n `(batch, spatial_dim1, spatial_dim2, spatial_dim3, channels)` while\n `\"channels_first\"` corresponds to inputs with shape\n `(batch, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.\n It defaults to the `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json`. If you never set it, then it\n will be `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 5D tensor with shape:\n `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`\n- If `data_format=\"channels_first\"`:\n 5D tensor with shape:\n `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 5D tensor with shape:\n `(batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels)`\n- If `data_format=\"channels_first\"`:\n 5D tensor with shape:\n `(batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "depth = 30\nheight = 30\nwidth = 30\nchannels = 3\n\ninputs = keras.layers.Input(shape=(depth, height, width, channels))\nlayer = keras.layers.AveragePooling3D(pool_size=3)\noutputs = layer(inputs) # Shape: (batch_size, 10, 10, 10, 3)"
- }
- ]
- },
- {
- "name": "LayerNormalization",
- "module": "keras.layers",
- "category": "Normalization",
- "description": "Layer normalization layer (Ba et al., 2016).\n\nNormalize the activations of the previous layer for each given example in a\nbatch independently, rather than across a batch like Batch Normalization.\ni.e. applies a transformation that maintains the mean activation within each\nexample close to 0 and the activation standard deviation close to 1.\n\nIf `scale` or `center` are enabled, the layer will scale the normalized\noutputs by broadcasting them with a trainable variable `gamma`, and center\nthe outputs by broadcasting with a trainable variable `beta`. `gamma` will\ndefault to a ones tensor and `beta` will default to a zeros tensor, so that\ncentering and scaling are no-ops before training has begun.\n\nSo, with scaling and centering enabled the normalization equations\nare as follows:\n\nLet the intermediate activations for a mini-batch to be the `inputs`.\n\nFor each sample `x_i` in `inputs` with `k` features, we compute the mean and\nvariance of the sample:\n\n```python\nmean_i = sum(x_i[j] for j in range(k)) / k\nvar_i = sum((x_i[j] - mean_i) ** 2 for j in range(k)) / k\n```\n\nand then compute a normalized `x_i_normalized`, including a small factor\n`epsilon` for numerical stability.\n\n```python\nx_i_normalized = (x_i - mean_i) / sqrt(var_i + epsilon)\n```\n\nAnd finally `x_i_normalized ` is linearly transformed by `gamma` and `beta`,\nwhich are learned parameters:\n\n```python\noutput_i = x_i_normalized * gamma + beta\n```\n\n`gamma` and `beta` will span the axes of `inputs` specified in `axis`, and\nthis part of the inputs' shape must be fully defined.\n\nFor example:\n\n```\n>>> layer = keras.layers.LayerNormalization(axis=[1, 2, 3])\n>>> layer.build([5, 20, 30, 40])\n>>> print(layer.beta.shape)\n(20, 30, 40)\n>>> print(layer.gamma.shape)\n(20, 30, 40)\n```\n\nNote that other implementations of layer normalization may choose to define\n`gamma` and `beta` over a separate set of axes from the axes being\nnormalized across. For example, Group Normalization\n([Wu et al. 2018](https://arxiv.org/abs/1803.08494)) with group size of 1\ncorresponds to a Layer Normalization that normalizes across height, width,\nand channel and has `gamma` and `beta` span only the channel dimension.\nSo, this Layer Normalization implementation will not match a Group\nNormalization layer with group size set to 1.",
- "attributes": [
- {
- "name": "axis",
- "description": "Integer or List/Tuple. The axis or axes to normalize across.\n Typically, this is the features axis/axes. The left-out axes are\n typically the batch axis/axes. `-1` is the last dimension in the\n input. Defaults to `-1`."
- },
- {
- "name": "epsilon",
- "description": "Small float added to variance to avoid dividing by zero.\n Defaults to 1e-3."
- },
- {
- "name": "center",
- "description": "If True, add offset of `beta` to normalized tensor. If False,\n `beta` is ignored. Defaults to `True`."
- },
- {
- "name": "scale",
- "description": "If True, multiply by `gamma`. If False, `gamma` is not used.\n When the next layer is linear (also e.g. `nn.relu`), this can be\n disabled since the scaling will be done by the next layer.\n Defaults to `True`."
- },
- {
- "name": "rms_scaling",
- "description": "If True, `center` and `scale` are ignored, and the\n inputs are scaled by `gamma` and the inverse square root\n of the square of all inputs. This is an approximate and faster\n approach that avoids ever computing the mean of the input. Note that\n this *isn't* equivalent to the computation that the\n `keras.layers.RMSNormalization` layer performs."
- },
- {
- "name": "beta_initializer",
- "description": "Initializer for the beta weight. Defaults to zeros."
- },
- {
- "name": "gamma_initializer",
- "description": "Initializer for the gamma weight. Defaults to ones."
- },
- {
- "name": "beta_regularizer",
- "description": "Optional regularizer for the beta weight.\n None by default."
- },
- {
- "name": "gamma_regularizer",
- "description": "Optional regularizer for the gamma weight.\n None by default."
- },
- {
- "name": "beta_constraint",
- "description": "Optional constraint for the beta weight.\n None by default."
- },
- {
- "name": "gamma_constraint",
- "description": "Optional constraint for the gamma weight.\n None by default."
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments (e.g. `name` and `dtype`)."
- }
- ],
- "inputs": [
- {
- "name": "input"
- },
- {
- "name": "gamma"
- },
- {
- "name": "beta"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Lei Ba et al., 2016](https://arxiv.org/abs/1607.06450)."
- }
- ]
- },
- {
- "name": "BatchNorm",
- "category": "Normalization",
- "attributes": [
- {
- "default": -1,
- "name": "axis"
- },
- {
- "default": 0.001,
- "name": "epsilon"
- },
- {
- "default": 0.99,
- "name": "momentum"
- },
- {
- "default": true,
- "name": "scale"
- },
- {
- "default": true,
- "name": "center"
- },
- {
- "default": {
- "class_name": "Ones",
- "config": {}
- },
- "name": "gamma_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "name": "moving_mean_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Ones",
- "config": {}
- },
- "name": "moving_variance_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "name": "beta_initializer",
- "visible": false
- },
- {
- "name": "beta_regularizer",
- "visible": false
- },
- {
- "name": "gamma_regularizer",
- "visible": false
- },
- {
- "name": "beta_constraint"
- },
- {
- "name": "gamma_constraint"
- }
- ],
- "inputs": [
- {
- "name": "input"
- },
- {
- "name": "gamma"
- },
- {
- "name": "beta"
- },
- {
- "name": "running_mean"
- },
- {
- "name": "running_std"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "BatchNormalization",
- "module": "keras.layers",
- "category": "Normalization",
- "description": "Layer that normalizes its inputs.\n\nBatch normalization applies a transformation that maintains the mean output\nclose to 0 and the output standard deviation close to 1.\n\nImportantly, batch normalization works differently during training and\nduring inference.\n\n**During training** (i.e. when using `fit()` or when calling the layer/model\nwith the argument `training=True`), the layer normalizes its output using\nthe mean and standard deviation of the current batch of inputs. That is to\nsay, for each channel being normalized, the layer returns\n`gamma * (batch - mean(batch)) / sqrt(var(batch) + epsilon) + beta`, where:\n\n- `epsilon` is small constant (configurable as part of the constructor\narguments)\n- `gamma` is a learned scaling factor (initialized as 1), which\ncan be disabled by passing `scale=False` to the constructor.\n- `beta` is a learned offset factor (initialized as 0), which\ncan be disabled by passing `center=False` to the constructor.\n\n**During inference** (i.e. when using `evaluate()` or `predict()` or when\ncalling the layer/model with the argument `training=False` (which is the\ndefault), the layer normalizes its output using a moving average of the\nmean and standard deviation of the batches it has seen during training. That\nis to say, it returns\n`gamma * (batch - self.moving_mean) / sqrt(self.moving_var+epsilon) + beta`.\n\n`self.moving_mean` and `self.moving_var` are non-trainable variables that\nare updated each time the layer in called in training mode, as such:\n\n- `moving_mean = moving_mean * momentum + mean(batch) * (1 - momentum)`\n- `moving_var = moving_var * momentum + var(batch) * (1 - momentum)`\n\nAs such, the layer will only normalize its inputs during inference\n*after having been trained on data that has similar statistics as the\ninference data*.",
- "attributes": [
- {
- "default": -1,
- "description": "Integer, the axis that should be normalized\n (typically the features axis). For instance, after a `Conv2D` layer\n with `data_format=\"channels_first\"`, use `axis=1`.",
- "name": "axis"
- },
- {
- "default": 0.001,
- "description": "Small float added to variance to avoid dividing by zero.",
- "name": "epsilon"
- },
- {
- "default": 0.99,
- "description": "Momentum for the moving average.",
- "name": "momentum"
- },
- {
- "default": true,
- "description": "If `True`, multiply by `gamma`. If `False`, `gamma` is not used.\n When the next layer is linear this can be disabled\n since the scaling will be done by the next layer.",
- "name": "scale",
- "type": "boolean"
- },
- {
- "default": true,
- "description": "If `True`, add offset of `beta` to normalized tensor.\n If `False`, `beta` is ignored.",
- "name": "center",
- "type": "boolean"
- },
- {
- "default": {
- "class_name": "Ones",
- "config": {}
- },
- "description": "Initializer for the gamma weight.",
- "name": "gamma_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the moving mean.",
- "name": "moving_mean_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Ones",
- "config": {}
- },
- "description": "Initializer for the moving variance.",
- "name": "moving_variance_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the beta weight.",
- "name": "beta_initializer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the beta weight.",
- "name": "beta_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the gamma weight.",
- "name": "gamma_regularizer",
- "visible": false
- },
- {
- "description": "Optional constraint for the beta weight.",
- "name": "beta_constraint"
- },
- {
- "description": "Optional constraint for the gamma weight.",
- "name": "gamma_constraint"
- },
- {
- "description": "Whether to use\n [Batch Renormalization](https://arxiv.org/abs/1702.03275). This\n adds extra variables during training. The inference is the same\n for either value of this parameter.",
- "name": "renorm"
- },
- {
- "description": "Dictionary, valid only if `renorm = True`.\n Maps optional keys `\"rmax\"`, `\"rmin\"`, `\"dmax\"` to floats used to\n clip the renorm correction. The correction `(r, d)` is used as\n `corrected_value = normalized_value * r + d`, with `r` clipped to\n `[rmin, rmax]`, and `d` to `[-dmax, dmax]`. Missing `rmax`, `rmin`,\n `dmax` are set to `inf`, `0`, `inf`, respectively.",
- "name": "renorm_clipping"
- },
- {
- "description": "Momentum used to update the moving means and standard\n deviations with renorm. Valid only if `renorm= True`. Unlike\n `momentum`, this affects training and should be neither too small\n (which would add noise) nor too large (which would give stale\n estimates). Note that `momentum` is still applied to get the means\n and variances for inference.",
- "name": "renorm_momentum"
- },
- {
- "description": "if `True`, use a faster, fused implementation, or raise a ValueError\n if the fused implementation cannot be used. If `None`, use the faster\n implementation if possible. If False, do not used the fused\n implementation.",
- "name": "fused"
- },
- {
- "description": "Boolean, if `True` the variables will be marked as trainable.",
- "name": "trainable"
- },
- {
- "description": "An `int`. By default, `virtual_batch_size` is `None`,\n which means batch normalization is performed across the whole batch. When\n `virtual_batch_size` is not `None`, instead perform \"Ghost Batch\n Normalization\", which creates virtual sub-batches which are each\n normalized separately (with shared gamma, beta, and moving statistics).\n Must divide the actual batch size during execution.",
- "name": "virtual_batch_size"
- },
- {
- "description": "A function taking the `Tensor` containing the (dynamic) shape of\n the input tensor and returning a pair (scale, bias) to apply to the\n normalized values (before gamma and beta), only during training. For\n example, if axis==-1,\n `adjustment = lambda shape: (\n tf.random.uniform(shape[-1:], 0.93, 1.07),\n tf.random.uniform(shape[-1:], -0.1, 0.1))` will scale the normalized\n value by up to 7% up or down, then shift the result by up to 0.1\n (with independent scaling and bias for each feature but shared\n across all examples), and finally apply gamma and/or beta. If\n `None`, no adjustment is applied. Cannot be specified if\n virtual_batch_size is specified.",
- "name": "adjustment"
- },
- {
- "name": "synchronized",
- "description": "Only applicable with the TensorFlow backend.\n If `True`, synchronizes the global batch statistics (mean and\n variance) for the layer across all devices at each training step\n in a distributed training strategy.\n If `False`, each replica uses its own local batch statistics."
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments (e.g. `name` and `dtype`)."
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape` (tuple of\nintegers, does not include the samples axis) when using this layer as the\nfirst layer in a model.",
- "name": "input"
- },
- {
- "name": "gamma"
- },
- {
- "name": "beta"
- },
- {
- "name": "moving_mean"
- },
- {
- "name": "moving_variance"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as input.\n\nReference:\n - [Ioffe and Szegedy, 2015](https://arxiv.org/abs/1502.03167).\n\n**About setting `layer.trainable = False` on a `BatchNormalization` layer:**\n\nThe meaning of setting `layer.trainable = False` is to freeze the layer,\ni.e. its internal state will not change during training:\nits trainable weights will not be updated\nduring `fit()` or `train_on_batch()`, and its state updates will not be run.\n\nUsually, this does not necessarily mean that the layer is run in inference\nmode (which is normally controlled by the `training` argument that can\nbe passed when calling a layer). \"Frozen state\" and \"inference mode\"\nare two separate concepts.\n\nHowever, in the case of the `BatchNormalization` layer, **setting\n`trainable = False` on the layer means that the layer will be\nsubsequently run in inference mode** (meaning that it will use\nthe moving mean and the moving variance to normalize the current batch,\nrather than using the mean and variance of the current batch).\n\nThis behavior has been introduced in TensorFlow 2.0, in order\nto enable `layer.trainable = False` to produce the most commonly\nexpected behavior in the convnet fine-tuning use case.\n\nNote that:\n - Setting `trainable` on an model containing other layers will\n recursively set the `trainable` value of all inner layers.\n - If the value of the `trainable`\n attribute is changed after calling `compile()` on a model,\n the new value doesn't take effect for this model\n until `compile()` is called again.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Ioffe and Szegedy, 2015](https://arxiv.org/abs/1502.03167). **About setting `layer.trainable = False` on a `BatchNormalization` layer:** The meaning of setting `layer.trainable = False` is to freeze the layer, i.e. its internal state will not change during training: its trainable weights will not be updated during `fit()` or `train_on_batch()`, and its state updates will not be run. Usually, this does not necessarily mean that the layer is run in inference mode (which is normally controlled by the `training` argument that can be passed when calling a layer). \"Frozen state\" and \"inference mode\" are two separate concepts. However, in the case of the `BatchNormalization` layer, **setting `trainable = False` on the layer means that the layer will be subsequently run in inference mode** (meaning that it will use the moving mean and the moving variance to normalize the current batch, rather than using the mean and variance of the current batch). Note that: "
- },
- {
- "description": "Setting `trainable` on an model containing other layers will recursively set the `trainable` value of all inner layers."
- },
- {
- "description": "If the value of the `trainable` attribute is changed after calling `compile()` on a model, the new value doesn't take effect for this model until `compile()` is called again."
- }
- ]
- },
- {
- "name": "Bidirectional",
- "module": "keras.layers",
- "description": "Bidirectional wrapper for RNNs.",
- "attributes": [
- {
- "default": "concat",
- "description": "Mode by which outputs of the forward and backward RNNs\n will be combined. One of `{\"sum\", \"mul\", \"concat\", \"ave\", None}`.\n If `None`, the outputs will not be combined,\n they will be returned as a list. Defaults to `\"concat\"`.",
- "name": "merge_mode"
- },
- {
- "description": "`keras.layers.RNN` instance, such as\n `keras.layers.LSTM` or `keras.layers.GRU`.\n It could also be a `keras.layers.Layer` instance\n that meets the following criteria:\n 1. Be a sequence-processing layer (accepts 3D+ inputs).\n 2. Have a `go_backwards`, `return_sequences` and `return_state`\n attribute (with the same semantics as for the `RNN` class).\n 3. Have an `input_spec` attribute.\n 4. Implement serialization via `get_config()` and `from_config()`.\n Note that the recommended way to create new RNN layers is to write a\n custom RNN cell and use it with `keras.layers.RNN`, instead of\n subclassing `keras.layers.Layer` directly.\n When `return_sequences` is `True`, the output of the masked\n timestep will be zero regardless of the layer's original\n `zero_output_for_mask` value.",
- "name": "layer"
- },
- {
- "description": "Initial weights to load in the Bidirectional model\n",
- "name": "weights"
- },
- {
- "description": "Optional `keras.layers.RNN`,\n or `keras.layers.Layer` instance to be used to handle\n backwards input processing.\n If `backward_layer` is not provided, the layer instance passed\n as the `layer` argument will be used to generate the backward layer\n automatically.\n Note that the provided `backward_layer` layer should have properties\n matching those of the `layer` argument, in particular\n it should have the same values for `stateful`, `return_states`,\n `return_sequences`, etc. In addition, `backward_layer`\n and `layer` should have different `go_backwards` argument values.\n A `ValueError` will be raised if these requirements are not met.",
- "name": "backward_layer"
- }
- ],
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "model = Sequential([\n Input(shape=(5, 10)),\n Bidirectional(LSTM(10, return_sequences=True),\n Bidirectional(LSTM(10)),\n Dense(5, activation=\"softmax\"),\n])\nmodel.compile(loss='categorical_crossentropy', optimizer='rmsprop')\n\n# With custom backward layer\nforward_layer = LSTM(10, return_sequences=True)\nbackward_layer = LSTM(10, activation='relu', return_sequences=True,\n go_backwards=True)\nmodel = Sequential([\n Input(shape=(5, 10)),\n Bidirectional(forward_layer, backward_layer=backward_layer),\n Dense(5, activation=\"softmax\"),\n])\nmodel.compile(loss='categorical_crossentropy', optimizer='rmsprop')"
- }
- ]
- },
- {
- "name": "Concatenate",
- "module": "keras.layers",
- "category": "Tensor",
- "description": "Concatenates a list of inputs.\n\nIt takes as input a list of tensors, all of the same shape except\nfor the concatenation axis, and returns a single tensor that is the\nconcatenation of all inputs.",
- "attributes": [
- {
- "description": "Axis along which to concatenate.",
- "name": "axis"
- },
- {
- "description": "Standard layer keyword arguments.",
- "name": "**kwargs"
- }
- ],
- "inputs": [
- {
- "name": "inputs",
- "list": true
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.arange(20).reshape(2, 2, 5)\n>>> y = np.arange(20, 30).reshape(2, 1, 5)\n>>> keras.layers.Concatenate(axis=1)([x, y])"
- },
- {
- "summary": "Usage in a Keras model:",
- "code": ">>> x1 = keras.layers.Dense(8)(np.arange(10).reshape(5, 2))\n>>> x2 = keras.layers.Dense(8)(np.arange(10, 20).reshape(5, 2))\n>>> y = keras.layers.Concatenate()([x1, x2])"
- }
- ]
- },
- {
- "name": "Conv1D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "1D convolution layer (e.g. temporal convolution).\n\nThis layer creates a convolution kernel that is convolved with the layer\ninput over a single spatial (or temporal) dimension to produce a tensor of\noutputs. If `use_bias` is True, a bias vector is created and added to the\noutputs. Finally, if `activation` is not `None`, it is applied to the\noutputs as well.",
- "attributes": [
- {
- "default": "linear",
- "description": "Activation function. If `None`, no activation is applied.",
- "name": "activation"
- },
- {
- "default": "valid",
- "description": "string, `\"valid\"`, `\"same\"` or `\"causal\"`(case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input. When `padding=\"same\"` and\n `strides=1`, the output has the same size as the input.\n `\"causal\"` results in causal(dilated) convolutions, e.g. `output[t]`\n does not depend on`input[t+1:]`. Useful when modeling temporal data\n where the model should not violate the temporal order.\n See [WaveNet: A Generative Model for Raw Audio, section2.1](\n https://arxiv.org/abs/1609.03499).",
- "name": "padding"
- },
- {
- "default": true,
- "description": "bool, if `True`, bias will be added to the output.",
- "name": "use_bias",
- "visible": false
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, steps, features)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, steps)`. It defaults to the `image_data_format`\n value found in your Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "default": [
- 1
- ],
- "description": "int or tuple/list of 1 integer, specifying the stride length\n of the convolution. `strides > 1` is incompatible with\n `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "default": [
- 1
- ],
- "description": "int or tuple/list of 1 integers, specifying the dilation\n rate to use for dilated convolution.",
- "name": "dilation_rate"
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the bias vector. If `None`, the\n default initializer (`\"zeros\"`) will be used.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "Initializer for the convolution kernel. If `None`,\n the default initializer (`\"glorot_uniform\"`) will be used.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "int, the dimension of the output space (the number of filters\n in the convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 1 integer, specifying the size of the\n convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "Optional regularizer for the convolution kernel.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer function for the output.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n kernel after being updated by an `Optimizer` (e.g. used to implement\n norm constraints or value constraints for layer weights). The\n function must take as input the unprojected variable and must return\n the projected variable (which must have the same shape). Constraints\n are not safe to use when doing asynchronous distributed training.",
- "name": "kernel_constraint"
- },
- {
- "description": "Optional projection function to be applied to the\n bias after being updated by an `Optimizer`.",
- "name": "bias_constraint"
- },
- {
- "description": "A positive int specifying the number of groups in which the\n input is split along the channel axis. Each group is convolved\n separately with `filters // groups` filters. The output is the\n concatenation of all the `groups` results along the channel axis.\n Input channels and `filters` must both be divisible by `groups`.",
- "name": "groups"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 3D tensor with shape: `(batch_shape, steps, channels)`\n- If `data_format=\"channels_first\"`:\n A 3D tensor with shape: `(batch_shape, channels, steps)`",
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 3D tensor with shape: `(batch_shape, new_steps, filters)`\n- If `data_format=\"channels_first\"`:\n A 3D tensor with shape: `(batch_shape, filters, new_steps)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> # The inputs are 128-length vectors with 10 timesteps, and the\n>>> # batch size is 4.\n>>> x = np.random.rand(4, 10, 128)\n>>> y = keras.layers.Conv1D(32, 3, activation='relu')(x)\n>>> print(y.shape)\n(4, 8, 32)"
- }
- ]
- },
- {
- "name": "Conv2D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "2D convolution layer.\n\nThis layer creates a convolution kernel that is convolved with the layer\ninput over a 2D spatial (or temporal) dimension (height and width) to\nproduce a tensor of outputs. If `use_bias` is True, a bias vector is created\nand added to the outputs. Finally, if `activation` is not `None`, it is\napplied to the outputs as well.\n\nNote on numerical precision: While in general Keras operation execution\nresults are identical across backends up to 1e-7 precision in float32,\n`Conv2D` operations may show larger variations. Due to the large\nnumber of element-wise multiplications and additions in convolution\noperations, especially with large inputs or kernel sizes, accumulated\nfloating-point differences can exceed this 1e-7 threshold. These variations\nare particularly noticeable when using different backends (e.g., TensorFlow\nvs JAX) or different hardware.",
- "attributes": [
- {
- "default": "linear",
- "description": "Activation function. If `None`, no activation is applied.",
- "name": "activation"
- },
- {
- "default": "valid",
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input. When `padding=\"same\"` and\n `strides=1`, the output has the same size as the input.",
- "name": "padding"
- },
- {
- "default": true,
- "description": "bool, if `True`, bias will be added to the output.",
- "name": "use_bias",
- "type": "boolean",
- "visible": false
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape\n `(batch_size, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch_size, channels, height, width)`. It defaults to the\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json`. If you never set it, then it will be\n `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "default": [
- 1,
- 1
- ],
- "description": "int or tuple/list of 2 integer, specifying the stride length\n of the convolution. `strides > 1` is incompatible with\n `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "default": [
- 1,
- 1
- ],
- "description": "int or tuple/list of 2 integers, specifying the dilation\n rate to use for dilated convolution.",
- "name": "dilation_rate"
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the bias vector. If `None`, the\n default initializer (`\"zeros\"`) will be used.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "Initializer for the convolution kernel. If `None`,\n the default initializer (`\"glorot_uniform\"`) will be used.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "int, the dimension of the output space (the number of filters\n in the convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 2 integer, specifying the size of the\n convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "Optional regularizer for the convolution kernel.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer function for the output.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n kernel after being updated by an `Optimizer` (e.g. used to implement\n norm constraints or value constraints for layer weights). The\n function must take as input the unprojected variable and must return\n the projected variable (which must have the same shape). Constraints\n are not safe to use when doing asynchronous distributed training.",
- "name": "kernel_constraint",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n bias after being updated by an `Optimizer`.",
- "name": "bias_constraint",
- "visible": false
- },
- {
- "description": "A positive int specifying the number of groups in which the\n input is split along the channel axis. Each group is convolved\n separately with `filters // groups` filters. The output is the\n concatenation of all the `groups` results along the channel axis.\n Input channels and `filters` must both be divisible by `groups`.",
- "name": "groups"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, height, width, channels)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, channels, height, width)`",
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, new_height, new_width, filters)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, filters, new_height, new_width)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(4, 10, 10, 128)\n>>> y = keras.layers.Conv2D(32, 3, activation='relu')(x)\n>>> print(y.shape)\n(4, 8, 8, 32)"
- }
- ]
- },
- {
- "name": "Conv2DTranspose",
- "module": "keras.layers",
- "category": "Layer",
- "description": "2D transposed convolution layer.\n\nThe need for transposed convolutions generally arise from the desire to use\na transformation going in the opposite direction of a normal convolution,\ni.e., from something that has the shape of the output of some convolution\nto something that has the shape of its input while maintaining a\nconnectivity pattern that is compatible with said convolution.",
- "attributes": [
- {
- "description": "int, the dimension of the output space (the number of filters\n in the transposed convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 1 integer, specifying the size of the\n transposed convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "int or tuple/list of 1 integer, specifying the stride length\n of the transposed convolution. `strides > 1` is incompatible with\n `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input. When `padding=\"same\"` and\n `strides=1`, the output has the same size as the input.",
- "name": "padding"
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape\n `(batch_size, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch_size, channels, height, width)`. It defaults to the\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json`. If you never set it, then it will be\n `\"channels_last\"`.\n dilation_rate: An integer or tuple/list of 2 integers,\n specifying the dilation rate for\n all spatial dimensions for dilated convolution.\n Specifying different dilation rates\n for different dimensions is not supported.\n Currently, specifying any `dilation_rate` value != 1 is\n incompatible with specifying any stride value != 1.",
- "name": "data_format"
- },
- {
- "description": "int or tuple/list of 1 integers, specifying the dilation\n rate to use for dilated transposed convolution.",
- "name": "dilation_rate"
- },
- {
- "description": "Activation function. If `None`, no activation is applied.",
- "name": "activation"
- },
- {
- "default": true,
- "description": "bool, if `True`, bias will be added to the output.",
- "name": "use_bias",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "Initializer for the convolution kernel. If `None`,\n the default initializer (`\"glorot_uniform\"`) will be used.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the bias vector. If `None`, the\n default initializer (`\"zeros\"`) will be used.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the convolution kernel.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer function for the output.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n kernel after being updated by an `Optimizer` (e.g. used to implement\n norm constraints or value constraints for layer weights). The\n function must take as input the unprojected variable and must return\n the projected variable (which must have the same shape). Constraints\n are not safe to use when doing asynchronous distributed training.",
- "name": "kernel_constraint"
- },
- {
- "description": "Optional projection function to be applied to the\n bias after being updated by an `Optimizer`.",
- "name": "bias_constraint"
- },
- {
- "description": "An integer or tuple/list of 2 integers,\n specifying the amount of padding along the height and width\n of the output tensor.\n Can be a single integer to specify the same value for all\n spatial dimensions.\n The amount of output padding along a given dimension must be\n lower than the stride along that same dimension.\n If set to `None` (default), the output shape is inferred.",
- "name": "output_padding"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, height, width, channels)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, channels, height, width)`",
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, new_height, new_width, filters)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, filters, new_height, new_width)`",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[A guide to convolution arithmetic for deep learning]( https://arxiv.org/abs/1603.07285v1)"
- },
- {
- "description": "[Deconvolutional Networks]( https://www.matthewzeiler.com/mattzeiler/deconvolutionalnetworks.pdf) "
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(4, 10, 8, 128)\n>>> y = keras.layers.Conv2DTranspose(32, 2, 2, activation='relu')(x)\n>>> print(y.shape)\n(4, 20, 16, 32)"
- }
- ]
- },
- {
- "name": "Conv3D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "3D convolution layer.\n\nThis layer creates a convolution kernel that is convolved with the layer\ninput over a 3D spatial (or temporal) dimension (width,height and depth) to\nproduce a tensor of outputs. If `use_bias` is True, a bias vector is created\nand added to the outputs. Finally, if `activation` is not `None`, it is\napplied to the outputs as well.",
- "attributes": [
- {
- "description": "int, the dimension of the output space (the number of filters\n in the convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 3 integer, specifying the size of the\n convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "int or tuple/list of 3 integer, specifying the stride length\n of the convolution. `strides > 1` is incompatible with\n `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input. When `padding=\"same\"` and\n `strides=1`, the output has the same size as the input.",
- "name": "padding"
- },
- {
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape\n `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.\n It defaults to the `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json`. If you never set it, then it\n will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "description": "int or tuple/list of 3 integers, specifying the dilation\n rate to use for dilated convolution.",
- "name": "dilation_rate"
- },
- {
- "description": "Activation function. If `None`, no activation is applied.",
- "name": "activation"
- },
- {
- "default": true,
- "description": "bool, if `True`, bias will be added to the output.",
- "name": "use_bias",
- "visible": false
- },
- {
- "description": "Initializer for the convolution kernel. If `None`,\n the default initializer (`\"glorot_uniform\"`) will be used.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector. If `None`, the\n default initializer (`\"zeros\"`) will be used.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the convolution kernel.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer function for the output.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n kernel after being updated by an `Optimizer` (e.g. used to implement\n norm constraints or value constraints for layer weights). The\n function must take as input the unprojected variable and must return\n the projected variable (which must have the same shape). Constraints\n are not safe to use when doing asynchronous distributed training.",
- "name": "kernel_constraint"
- },
- {
- "description": "Optional projection function to be applied to the\n bias after being updated by an `Optimizer`.",
- "name": "bias_constraint"
- },
- {
- "description": "A positive int specifying the number of groups in which the\n input is split along the channel axis. Each group is convolved\n separately with `filters // groups` filters. The output is the\n concatenation of all the `groups` results along the channel axis.\n Input channels and `filters` must both be divisible by `groups`.",
- "name": "groups"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 5D tensor with shape:\n `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`\n- If `data_format=\"channels_first\"`:\n 5D tensor with shape:\n `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 5D tensor with shape:\n `(batch_size, new_spatial_dim1, new_spatial_dim2, new_spatial_dim3,\n filters)`\n- If `data_format=\"channels_first\"`:\n 5D tensor with shape:\n `(batch_size, filters, new_spatial_dim1, new_spatial_dim2,\n new_spatial_dim3)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(4, 10, 10, 10, 128)\n>>> y = keras.layers.Conv3D(32, 3, activation='relu')(x)\n>>> print(y.shape)\n(4, 8, 8, 8, 32)"
- }
- ]
- },
- {
- "name": "ConvLSTM2D",
- "module": "keras.layers",
- "description": "2D Convolutional LSTM.\n\nSimilar to an LSTM layer, but the input transformations\nand recurrent transformations are both convolutional.",
- "attributes": [
- {
- "description": "int, the dimension of the output space (the number of filters\n in the convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 2 integers, specifying the size of the\n convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "int or tuple/list of 2 integers, specifying the stride length\n of the convolution. `strides > 1` is incompatible with\n `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "description": "string, `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input such that output has the same\n height/width dimension as the input.",
- "name": "padding"
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, steps, features)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, steps)`. It defaults to the `image_data_format`\n value found in your Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "description": "int or tuple/list of 2 integers, specifying the dilation\n rate to use for dilated convolution.",
- "name": "dilation_rate"
- },
- {
- "description": "Activation function to use. By default hyperbolic tangent\n activation function is applied (`tanh(x)`).",
- "name": "activation"
- },
- {
- "description": "Activation function to use for the recurrent step.",
- "name": "recurrent_activation"
- },
- {
- "default": true,
- "description": "Boolean, whether the layer uses a bias vector.",
- "name": "use_bias",
- "visible": false
- },
- {
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the `recurrent_kernel` weights\n matrix, used for the linear transformation of the recurrent state.",
- "name": "recurrent_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Boolean. If `True`, add 1 to the bias of the forget\n gate at initialization.\n Use in combination with `bias_initializer=\"zeros\"`.\n This is recommended in [Jozefowicz et al., 2015](\n http://www.jmlr.org/proceedings/papers/v37/jozefowicz15.pdf)",
- "name": "unit_forget_bias"
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the\n `recurrent_kernel` weights matrix.",
- "name": "recurrent_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to the `kernel` weights\n matrix.",
- "name": "kernel_constraint",
- "visible": false
- },
- {
- "description": "Constraint function applied to the\n `recurrent_kernel` weights matrix.",
- "name": "recurrent_constraint",
- "visible": false
- },
- {
- "description": "Constraint function applied to the bias vector.",
- "name": "bias_constraint",
- "visible": false
- },
- {
- "description": "Boolean. Whether to return the last output\n in the output sequence, or the full sequence. Default: `False`.",
- "name": "return_sequences"
- },
- {
- "description": "Boolean (default: `False`).\n If `True`, process the input sequence backwards and return the\n reversed sequence.",
- "name": "go_backwards"
- },
- {
- "description": "Boolean (default False). If `True`, the last state\n for each sample at index i in a batch will be used as initial\n state for the sample of index i in the following batch.",
- "name": "stateful"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop for the\n linear transformation of the inputs.",
- "name": "dropout"
- },
- {
- "description": "Float between 0 and 1. Fraction of the units to drop\n for the linear transformation of the recurrent state.",
- "name": "recurrent_dropout"
- },
- {
- "description": "Boolean. Whether to return the last state in addition\n to the output. Default: `False`.",
- "name": "return_state"
- },
- {
- "name": "seed",
- "description": "Random seed for dropout."
- },
- {
- "name": "unroll",
- "description": "Boolean (default: `False`).\n If `True`, the network will be unrolled,\n else a symbolic loop will be used.\n Unrolling can speed-up a RNN,\n although it tends to be more memory-intensive.\n Unrolling is only suitable for short sequences."
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format='channels_first'`:\n 5D tensor with shape: `(samples, time, channels, rows, cols)`\n- If `data_format='channels_last'`:\n 5D tensor with shape: `(samples, time, rows, cols, channels)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `return_state`: a list of tensors. The first tensor is the output.\n The remaining tensors are the last states,\n each 4D tensor with shape: `(samples, filters, new_rows, new_cols)` if\n `data_format='channels_first'`\n or shape: `(samples, new_rows, new_cols, filters)` if\n `data_format='channels_last'`. `rows` and `cols` values might have\n changed due to padding.\n- If `return_sequences`: 5D tensor with shape: `(samples, timesteps,\n filters, new_rows, new_cols)` if data_format='channels_first'\n or shape: `(samples, timesteps, new_rows, new_cols, filters)` if\n `data_format='channels_last'`.\n- Else, 4D tensor with shape: `(samples, filters, new_rows, new_cols)` if\n `data_format='channels_first'`\n or shape: `(samples, new_rows, new_cols, filters)` if\n `data_format='channels_last'`.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "steps = 10\nheight = 32\nwidth = 32\ninput_channels = 3\noutput_channels = 6\n\ninputs = tf.keras.Input(shape=(steps, height, width, input_channels))\nlayer = tf.keras.layers.ConvLSTM2D(filters=output_channels, kernel_size=3)\noutputs = layer(inputs)"
- }
- ],
- "references": [
- {
- "description": "[Shi et al., 2015](http://arxiv.org/abs/1506.04214v1) (the current implementation does not include the feedback loop on the cells output)."
- }
- ]
- },
- {
- "name": "Convolution2D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "2D convolution layer.\n\nThis layer creates a convolution kernel that is convolved with the layer\ninput over a 2D spatial (or temporal) dimension (height and width) to\nproduce a tensor of outputs. If `use_bias` is True, a bias vector is created\nand added to the outputs. Finally, if `activation` is not `None`, it is\napplied to the outputs as well.\n\nNote on numerical precision: While in general Keras operation execution\nresults are identical across backends up to 1e-7 precision in float32,\n`Conv2D` operations may show larger variations. Due to the large\nnumber of element-wise multiplications and additions in convolution\noperations, especially with large inputs or kernel sizes, accumulated\nfloating-point differences can exceed this 1e-7 threshold. These variations\nare particularly noticeable when using different backends (e.g., TensorFlow\nvs JAX) or different hardware.",
- "attributes": [
- {
- "default": "linear",
- "description": "Activation function. If `None`, no activation is applied.",
- "name": "activation"
- },
- {
- "default": "valid",
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input. When `padding=\"same\"` and\n `strides=1`, the output has the same size as the input.",
- "name": "padding"
- },
- {
- "default": true,
- "description": "bool, if `True`, bias will be added to the output.",
- "name": "use_bias",
- "visible": false
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape\n `(batch_size, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch_size, channels, height, width)`. It defaults to the\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json`. If you never set it, then it will be\n `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "default": [
- 1,
- 1
- ],
- "description": "int or tuple/list of 2 integer, specifying the stride length\n of the convolution. `strides > 1` is incompatible with\n `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "default": [
- 1,
- 1
- ],
- "description": "int or tuple/list of 2 integers, specifying the dilation\n rate to use for dilated convolution.",
- "name": "dilation_rate"
- },
- {
- "default": 1,
- "name": "depth_multiplier"
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the bias vector. If `None`, the\n default initializer (`\"zeros\"`) will be used.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "Initializer for the convolution kernel. If `None`,\n the default initializer (`\"glorot_uniform\"`) will be used.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "int, the dimension of the output space (the number of filters\n in the convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 2 integer, specifying the size of the\n convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "Optional regularizer for the convolution kernel.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer function for the output.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n kernel after being updated by an `Optimizer` (e.g. used to implement\n norm constraints or value constraints for layer weights). The\n function must take as input the unprojected variable and must return\n the projected variable (which must have the same shape). Constraints\n are not safe to use when doing asynchronous distributed training.",
- "name": "kernel_constraint"
- },
- {
- "description": "Optional projection function to be applied to the\n bias after being updated by an `Optimizer`.",
- "name": "bias_constraint"
- },
- {
- "description": "A positive int specifying the number of groups in which the\n input is split along the channel axis. Each group is convolved\n separately with `filters // groups` filters. The output is the\n concatenation of all the `groups` results along the channel axis.\n Input channels and `filters` must both be divisible by `groups`.",
- "name": "groups"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, height, width, channels)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, channels, height, width)`",
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, new_height, new_width, filters)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, filters, new_height, new_width)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(4, 10, 10, 128)\n>>> y = keras.layers.Conv2D(32, 3, activation='relu')(x)\n>>> print(y.shape)\n(4, 8, 8, 32)"
- }
- ]
- },
- {
- "name": "Cropping1D",
- "module": "keras.layers",
- "category": "Shape",
- "description": "Cropping layer for 1D input (e.g. temporal sequence).\n\nIt crops along the time dimension (axis 1).",
- "attributes": [
- {
- "description": "Int, or tuple of int (length 2), or dictionary.\n - If int: how many units should be trimmed off at the beginning and\n end of the cropping dimension (axis 1).\n - If tuple of 2 ints: how many units should be trimmed off at the\n beginning and end of the cropping dimension\n (`(left_crop, right_crop)`).",
- "name": "cropping"
- }
- ],
- "inputs": [
- {
- "description": "3D tensor with shape `(batch_size, axis_to_crop, features)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "3D tensor with shape `(batch_size, cropped_axis, features)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 3, 2)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> x\n[[[ 0 1]\n [ 2 3]\n [ 4 5]]\n [[ 6 7]\n [ 8 9]\n [10 11]]]\n>>> y = keras.layers.Cropping1D(cropping=1)(x)\n>>> y\n[[[2 3]]\n [[8 9]]]"
- }
- ]
- },
- {
- "name": "Cropping2D",
- "module": "keras.layers",
- "category": "Shape",
- "description": "Cropping layer for 2D input (e.g. picture).\n\nIt crops along spatial dimensions, i.e. height and width.",
- "attributes": [
- {
- "description": "Int, or tuple of 2 ints, or tuple of 2 tuples of 2 ints.\n - If int: the same symmetric cropping is applied to height and\n width.\n - If tuple of 2 ints: interpreted as two different symmetric\n cropping values for height and width:\n `(symmetric_height_crop, symmetric_width_crop)`.\n - If tuple of 2 tuples of 2 ints: interpreted as\n `((top_crop, bottom_crop), (left_crop, right_crop))`.",
- "name": "cropping"
- },
- {
- "description": "A string, one of `\"channels_last\"` (default) or\n `\"channels_first\"`. The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch_size, height, width, channels)` while `\"channels_first\"`\n corresponds to inputs with shape\n `(batch_size, channels, height, width)`.\n When unspecified, uses `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json` (if exists). Defaults to\n `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "4D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, height, width, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, height, width)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "4D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, cropped_height, cropped_width, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, cropped_height, cropped_width)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 28, 28, 3)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> y = keras.layers.Cropping2D(cropping=((2, 2), (4, 4)))(x)\n>>> y.shape\n(2, 24, 20, 3)"
- }
- ]
- },
- {
- "name": "Cropping3D",
- "module": "keras.layers",
- "category": "Shape",
- "description": "Cropping layer for 3D data (e.g. spatial or spatio-temporal).",
- "attributes": [
- {
- "description": "Int, or tuple of 3 ints, or tuple of 3 tuples of 2 ints.\n - If int: the same symmetric cropping is applied to depth, height,\n and width.\n - If tuple of 3 ints: interpreted as three different symmetric\n cropping values for depth, height, and width:\n `(symmetric_dim1_crop, symmetric_dim2_crop, symmetric_dim3_crop)`.\n - If tuple of 3 tuples of 2 ints: interpreted as\n `((left_dim1_crop, right_dim1_crop), (left_dim2_crop,\n right_dim2_crop), (left_dim3_crop, right_dim3_crop))`.",
- "name": "cropping"
- },
- {
- "description": "A string, one of `\"channels_last\"` (default) or\n `\"channels_first\"`. The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.\n When unspecified, uses `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json` (if exists). Defaults to\n `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "5D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, first_axis_to_crop, second_axis_to_crop,\n third_axis_to_crop, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, first_axis_to_crop, second_axis_to_crop,\n third_axis_to_crop)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "5D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, first_cropped_axis, second_cropped_axis,\n third_cropped_axis, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, first_cropped_axis, second_cropped_axis,\n third_cropped_axis)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 28, 28, 10, 3)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> y = keras.layers.Cropping3D(cropping=(2, 4, 2))(x)\n>>> y.shape\n(2, 24, 20, 6, 3)"
- }
- ]
- },
- {
- "name": "CuDNNGRU",
- "description": "Fast GRU implementation backed by [CuDNN](https://developer.nvidia.com/cudnn).\n\nCan only be run on GPU, with the TensorFlow backend.\n",
- "attributes": [
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs.\n (see [initializers](https://keras.io/initializers)).",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the `recurrent_kernel`\n weights matrix,\n used for the linear transformation of the recurrent state.\n (see [initializers](https://keras.io/initializers)).",
- "name": "recurrent_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector\n (see [initializers](https://keras.io/initializers)).",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to\n the `kernel` weights matrix\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to\n the `recurrent_kernel` weights matrix\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "recurrent_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to\n the output of the layer (its \"activation\").\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to\n the `kernel` weights matrix\n (see [constraints](https://keras.io/constraints)).",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to\n the `recurrent_kernel` weights matrix\n (see [constraints](https://keras.io/constraints)).",
- "name": "recurrent_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector\n (see [constraints](https://keras.io/constraints)).",
- "name": "bias_constraint"
- },
- {
- "description": "Boolean. Whether to return the last output.\n in the output sequence, or the full sequence.",
- "name": "return_sequences"
- },
- {
- "description": "Boolean. Whether to return the last state\n in addition to the output.",
- "name": "return_state"
- },
- {
- "description": "Boolean (default False). If True, the last state\n for each sample at index i in a batch will be used as initial\n state for the sample of index i in the following batch.\n",
- "name": "stateful"
- }
- ]
- },
- {
- "name": "CuDNNLSTM",
- "description": "Fast LSTM implementation with [CuDNN](https://developer.nvidia.com/cudnn).\n\nCan only be run on GPU, with the TensorFlow backend.\n",
- "attributes": [
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs.\n (see [initializers](https://keras.io/initializers)).",
- "name": "kernel_initializer"
- },
- {
- "description": "Initializer for the `recurrent_kernel`\n weights matrix,\n used for the linear transformation of the recurrent state.\n (see [initializers](https://keras.io/initializers)).",
- "name": "recurrent_initializer"
- },
- {
- "description": "Initializer for the bias vector\n (see [initializers](https://keras.io/initializers)).",
- "name": "bias_initializer"
- },
- {
- "description": "Boolean.\n If True, add 1 to the bias of the forget gate at initialization.\n Setting it to true will also force `bias_initializer=\"zeros\"`.\n This is recommended in [Jozefowicz et al. (2015)](\n http://www.jmlr.org/proceedings/papers/v37/jozefowicz15.pdf).",
- "name": "unit_forget_bias"
- },
- {
- "description": "Regularizer function applied to\n the `kernel` weights matrix\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "kernel_regularizer"
- },
- {
- "description": "Regularizer function applied to\n the `recurrent_kernel` weights matrix\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "recurrent_regularizer"
- },
- {
- "description": "Regularizer function applied to the bias vector\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "bias_regularizer"
- },
- {
- "description": "Regularizer function applied to\n the output of the layer (its \"activation\").\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "activity_regularizer"
- },
- {
- "description": "Constraint function applied to\n the `kernel` weights matrix\n (see [constraints](https://keras.io/constraints)).",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to\n the `recurrent_kernel` weights matrix\n (see [constraints](https://keras.io/constraints)).",
- "name": "recurrent_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector\n (see [constraints](https://keras.io/constraints)).",
- "name": "bias_constraint"
- },
- {
- "description": "Boolean. Whether to return the last output.\n in the output sequence, or the full sequence.",
- "name": "return_sequences"
- },
- {
- "description": "Boolean. Whether to return the last state\n in addition to the output.",
- "name": "return_state"
- },
- {
- "description": "Boolean (default False). If True, the last state\n for each sample at index i in a batch will be used as initial\n state for the sample of index i in the following batch.\n",
- "name": "stateful"
- }
- ]
- },
- {
- "name": "Dense",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Just your regular densely-connected NN layer.\n\n`Dense` implements the operation:\n`output = activation(dot(input, kernel) + bias)`\nwhere `activation` is the element-wise activation function\npassed as the `activation` argument, `kernel` is a weights matrix\ncreated by the layer, and `bias` is a bias vector created by the layer\n(only applicable if `use_bias` is `True`). When this layer is\nfollowed by a `BatchNormalization` layer, it is recommended to set\n`use_bias=False` as `BatchNormalization` has its own bias term.\n\nNote: If the input to the layer has a rank greater than 2, `Dense`\ncomputes the dot product between the `inputs` and the `kernel` along the\nlast axis of the `inputs` and axis 0 of the `kernel` (using `tf.tensordot`).\nFor example, if input has dimensions `(batch_size, d0, d1)`, then we create\na `kernel` with shape `(d1, units)`, and the `kernel` operates along axis 2\nof the `input`, on every sub-tensor of shape `(1, 1, d1)` (there are\n`batch_size * d0` such sub-tensors). The output in this case will have\nshape `(batch_size, d0, units)`.",
- "attributes": [
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "default": "linear",
- "description": "Activation function to use.\n If you don't specify anything, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "default": true,
- "description": "Boolean, whether the layer uses a bias vector.",
- "name": "use_bias",
- "type": "boolean"
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "Initializer for the `kernel` weights matrix.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the bias vector.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to\n the `kernel` weights matrix.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to\n the output of the layer (its \"activation\").",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to\n the `kernel` weights matrix.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.",
- "name": "bias_constraint"
- },
- {
- "name": "lora_rank",
- "description": "Optional integer. If set, the layer's forward pass\n will implement LoRA (Low-Rank Adaptation)\n with the provided rank. LoRA sets the layer's kernel\n to non-trainable and replaces it with a delta over the\n original kernel, obtained via multiplying two lower-rank\n trainable matrices. This can be useful to reduce the\n computation cost of fine-tuning large dense layers.\n You can also enable LoRA on an existing\n `Dense` layer by calling `layer.enable_lora(rank)`."
- },
- {
- "name": "lora_alpha",
- "description": "Optional integer. If set, this parameter scales the\n low-rank adaptation delta (computed as the product of two lower-rank\n trainable matrices) during the forward pass. The delta is scaled by\n `lora_alpha / lora_rank`, allowing you to fine-tune the strength of\n the LoRA adjustment independently of `lora_rank`."
- }
- ],
- "inputs": [
- {
- "description": "N-D tensor with shape: `(batch_size, ..., input_dim)`.\nThe most common situation would be\na 2D input with shape `(batch_size, input_dim)`.",
- "name": "input",
- "type": "T"
- },
- {
- "name": "kernel",
- "type": "T"
- },
- {
- "name": "bias",
- "type": "T"
- }
- ],
- "outputs": [
- {
- "description": "N-D tensor with shape: `(batch_size, ..., units)`.\nFor instance, for a 2D input with shape `(batch_size, input_dim)`,\nthe output would have shape `(batch_size, units)`.",
- "name": "output",
- "type": "T"
- }
- ],
- "examples": [
- {
- "code": ">>> # Create a `Sequential` model and add a Dense layer as the first layer.\n>>> model = tf.keras.models.Sequential()\n>>> model.add(tf.keras.Input(shape=(16,)))\n>>> model.add(tf.keras.layers.Dense(32, activation='relu'))\n>>> # Now the model will take as input arrays of shape (None, 16)\n>>> # and output arrays of shape (None, 32).\n>>> # Note that after the first layer, you don't need to specify\n>>> # the size of the input anymore:\n>>> model.add(tf.keras.layers.Dense(32))\n>>> model.output_shape\n(None, 32)"
- }
- ]
- },
- {
- "name": "DepthwiseConv2D",
- "category": "Layer",
- "attributes": [
- {
- "default": "linear",
- "name": "activation"
- },
- {
- "default": "valid",
- "name": "padding"
- },
- {
- "default": true,
- "name": "use_bias",
- "type": "boolean",
- "visible": false
- },
- {
- "default": "channels_last",
- "name": "data_format"
- },
- {
- "default": [
- 1,
- 1
- ],
- "name": "strides"
- },
- {
- "default": [
- 1,
- 1
- ],
- "name": "dilation_rate"
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "name": "depthwise_initializer",
- "visible": false
- },
- {
- "default": 1,
- "name": "depth_multiplier"
- }
- ],
- "inputs": [
- {
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "Dot",
- "module": "keras.layers",
- "description": "Computes element-wise dot product of two tensors.\n\nIt takes a list of inputs of size 2, and the axes\ncorresponding to each input along with the dot product\nis to be performed.\n\nLet's say `x` and `y` are the two input tensors with shapes\n`(2, 3, 5)` and `(2, 10, 3)`. The batch dimension should be\nof same size for both the inputs, and `axes` should correspond\nto the dimensions that have the same size in the corresponding\ninputs. e.g. with `axes=(1, 2)`, the dot product of `x`, and `y`\nwill result in a tensor with shape `(2, 5, 10)`",
- "attributes": [
- {
- "description": "Integer or tuple of integers, axis or axes along which to\n take the dot product. If a tuple, should be two integers\n corresponding to the desired axis from the first input and the\n desired axis from the second input, respectively. Note that the\n size of the two selected axes must match, and that\n axis `0` (the batch axis) cannot be included.",
- "name": "axes"
- },
- {
- "description": "Whether to L2-normalize samples along the dot product axis\n before taking the dot product. If set to `True`, then\n the output of the dot product is the cosine proximity\n between the two samples.",
- "name": "normalize"
- },
- {
- "description": "Standard layer keyword arguments.",
- "name": "**kwargs"
- }
- ],
- "inputs": [
- {
- "name": "x"
- },
- {
- "name": "y"
- }
- ],
- "outputs": [
- {
- "name": "z"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.arange(10).reshape(1, 5, 2)\n>>> y = np.arange(10, 20).reshape(1, 2, 5)\n>>> keras.layers.Dot(axes=(1, 2))([x, y])"
- },
- {
- "summary": "Usage in a Keras model:",
- "code": ">>> x1 = keras.layers.Dense(8)(np.arange(10).reshape(5, 2))\n>>> x2 = keras.layers.Dense(8)(np.arange(10, 20).reshape(5, 2))\n>>> y = keras.layers.Dot(axes=1)([x1, x2])"
- }
- ]
- },
- {
- "name": "Dropout",
- "module": "keras.layers",
- "category": "Dropout",
- "description": "Applies dropout to the input.\n\nThe `Dropout` layer randomly sets input units to 0 with a frequency of\n`rate` at each step during training time, which helps prevent overfitting.\nInputs not set to 0 are scaled up by `1 / (1 - rate)` such that the sum over\nall inputs is unchanged.\n\nNote that the `Dropout` layer only applies when `training` is set to `True`\nin `call()`, such that no values are dropped during inference.\nWhen using `model.fit`, `training` will be appropriately set to `True`\nautomatically. In other contexts, you can set the argument explicitly\nto `True` when calling the layer.\n\n(This is in contrast to setting `trainable=False` for a `Dropout` layer.\n`trainable` does not affect the layer's behavior, as `Dropout` does\nnot have any variables/weights that can be frozen during training.)",
- "attributes": [
- {
- "description": "Float between 0 and 1. Fraction of the input units to drop.",
- "name": "rate"
- },
- {
- "description": "1D integer tensor representing the shape of the\n binary dropout mask that will be multiplied with the input.\n For instance, if your inputs have shape\n `(batch_size, timesteps, features)` and\n you want the dropout mask to be the same for all timesteps,\n you can use `noise_shape=(batch_size, 1, features)`.",
- "name": "noise_shape"
- },
- {
- "description": "A Python integer to use as random seed.",
- "name": "seed"
- }
- ],
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Dropout: A Simple Way to Prevent Neural Networks from Overfitting]( http://www.jmlr.org/papers/volume15/srivastava14a/srivastava14a.pdf)"
- }
- ]
- },
- {
- "name": "ELU",
- "module": "keras.layers",
- "category": "Activation",
- "description": "Applies an Exponential Linear Unit function to an output.\n\nFormula:\n\n```\nf(x) = alpha * (exp(x) - 1.) for x < 0\nf(x) = x for x >= 0\n```",
- "attributes": [
- {
- "description": "float, slope of negative section. Defaults to `1.0`.",
- "name": "alpha"
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments, such as `name` and `dtype`."
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the samples axis)\nwhen using this layer as the first layer in a model.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as the input.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)](https://arxiv.org/abs/1511.07289v1)"
- }
- ]
- },
- {
- "name": "Embedding",
- "module": "keras.layers",
- "category": "Transform",
- "description": "Turns nonnegative integers (indexes) into dense vectors of fixed size.\n\ne.g. `[[4], [20]] -> [[0.25, 0.1], [0.6, -0.2]]`\n\nThis layer can only be used on nonnegative integer inputs of a fixed range.",
- "attributes": [
- {
- "default": false,
- "description": "Boolean, whether or not the input value 0 is a special\n \"padding\" value that should be masked out.\n This is useful when using recurrent layers which\n may take variable length input. If this is `True`,\n then all subsequent layers in the model need\n to support masking or an exception will be raised.\n If `mask_zero` is set to `True`, as a consequence,\n index 0 cannot be used in the vocabulary (`input_dim` should\n equal size of vocabulary + 1).",
- "name": "mask_zero"
- },
- {
- "default": {
- "class_name": "RandomUniform",
- "config": {
- "maxval": 0.05,
- "minval": -0.05,
- "seed": null
- }
- },
- "description": "Initializer for the `embeddings`\n matrix (see `keras.initializers`).",
- "name": "embeddings_initializer",
- "visible": false
- },
- {
- "description": "Integer. Size of the vocabulary,\n i.e. maximum integer index + 1.",
- "name": "input_dim"
- },
- {
- "description": "Integer. Dimension of the dense embedding.",
- "name": "output_dim"
- },
- {
- "description": "Regularizer function applied to\n the `embeddings` matrix (see `keras.regularizers`).",
- "name": "embeddings_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to\n the `embeddings` matrix (see `keras.constraints`).",
- "name": "embeddings_constraint"
- },
- {
- "description": "Length of input sequences, when it is constant.\n This argument is required if you are going to connect\n `Flatten` then `Dense` layers upstream\n (without it, the shape of the dense outputs cannot be computed).",
- "name": "input_length"
- },
- {
- "description": "Regularizer function applied to\n the output of the layer (its \"activation\").\n (see [regularizer](https://keras.io/regularizers)).",
- "name": "activity_regularizer"
- },
- {
- "name": "sparse",
- "description": "If True, calling this layer returns a `tf.SparseTensor`. If False,\n the layer returns a dense `tf.Tensor`. For an entry with no features in\n a sparse tensor (entry with value 0), the embedding vector of index 0 is\n returned by default."
- },
- {
- "name": "lora_rank",
- "description": "Optional integer. If set, the layer's forward pass\n will implement LoRA (Low-Rank Adaptation)\n with the provided rank. LoRA sets the layer's embeddings\n matrix to non-trainable and replaces it with a delta over the\n original matrix, obtained via multiplying two lower-rank\n trainable matrices. This can be useful to reduce the\n computation cost of fine-tuning large embedding layers.\n You can also enable LoRA on an existing\n `Embedding` layer by calling `layer.enable_lora(rank)`."
- },
- {
- "name": "weights",
- "description": "Optional floating-point matrix of size\n `(input_dim, output_dim)`. The initial embeddings values\n to use."
- },
- {
- "name": "lora_alpha",
- "description": "Optional integer. If set, this parameter scales the\n low-rank adaptation delta (computed as the product of two lower-rank\n trainable matrices) during the forward pass. The delta is scaled by\n `lora_alpha / lora_rank`, allowing you to fine-tune the strength of\n the LoRA adjustment independently of `lora_rank`."
- }
- ],
- "inputs": [
- {
- "description": "2D tensor with shape: `(batch_size, input_length)`.",
- "name": "input"
- },
- {
- "name": "embeddings"
- }
- ],
- "outputs": [
- {
- "description": "3D tensor with shape: `(batch_size, input_length, output_dim)`.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[A Theoretically Grounded Application of Dropout in Recurrent Neural Networks](http://arxiv.org/abs/1512.05287)"
- }
- ],
- "examples": [
- {
- "code": ">>> model = keras.Sequential()\n>>> model.add(keras.layers.Embedding(1000, 64))\n>>> # The model will take as input an integer matrix of size (batch,\n>>> # input_length), and the largest integer (i.e. word index) in the input\n>>> # should be no larger than 999 (vocabulary size).\n>>> # Now model.output_shape is (None, 10, 64), where `None` is the batch\n>>> # dimension.\n>>> input_array = np.random.randint(1000, size=(32, 10))\n>>> model.compile('rmsprop', 'mse')\n>>> output_array = model.predict(input_array)\n>>> print(output_array.shape)\n(32, 10, 64)"
- }
- ]
- },
- {
- "name": "Flatten",
- "module": "keras.layers",
- "category": "Shape",
- "description": "Flattens the input. Does not affect the batch size.\n\nNote: If inputs are shaped `(batch,)` without a feature axis, then\nflattening adds an extra channel dimension and output shape is `(batch, 1)`.",
- "attributes": [
- {
- "default": "channels_last",
- "description": "A string, one of `\"channels_last\"` (default) or\n `\"channels_first\"`. The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch, ..., channels)` while `\"channels_first\"` corresponds to\n inputs with shape `(batch, channels, ...)`.\n When unspecified, uses `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json` (if exists). Defaults to\n `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = keras.Input(shape=(10, 64))\n>>> y = keras.layers.Flatten()(x)\n>>> y.shape\n(None, 640)"
- }
- ]
- },
- {
- "name": "GlobalAveragePooling1D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Global average pooling operation for temporal data.",
- "attributes": [
- {
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, steps, features)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, steps)`. It defaults to the `image_data_format`\n value found in your Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "name": "keepdims",
- "description": "A boolean, whether to keep the temporal dimension or not.\n If `keepdims` is `False` (default), the rank of the tensor is\n reduced for spatial dimensions. If `keepdims` is `True`, the\n temporal dimension are retained with length 1.\n The behavior is the same as for `tf.reduce_mean` or `np.mean`."
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format='channels_last'`:\n 3D tensor with shape:\n `(batch_size, steps, features)`\n- If `data_format='channels_first'`:\n 3D tensor with shape:\n `(batch_size, features, steps)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `keepdims=False`:\n 2D tensor with shape `(batch_size, features)`.\n- If `keepdims=True`:\n - If `data_format=\"channels_last\"`:\n 3D tensor with shape `(batch_size, 1, features)`\n - If `data_format=\"channels_first\"`:\n 3D tensor with shape `(batch_size, features, 1)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(2, 3, 4)\n>>> y = keras.layers.GlobalAveragePooling1D()(x)\n>>> y.shape\n(2, 4)"
- }
- ]
- },
- {
- "name": "GlobalAveragePooling2D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Global average pooling operation for 2D data.",
- "attributes": [
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, height, weight)`. It defaults to the\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json`. If you never set it, then it will be\n `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "name": "keepdims",
- "description": "A boolean, whether to keep the temporal dimension or not.\n If `keepdims` is `False` (default), the rank of the tensor is\n reduced for spatial dimensions. If `keepdims` is `True`, the\n spatial dimension are retained with length 1.\n The behavior is the same as for `tf.reduce_mean` or `np.mean`."
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format='channels_last'`:\n 4D tensor with shape:\n `(batch_size, height, width, channels)`\n- If `data_format='channels_first'`:\n 4D tensor with shape:\n `(batch_size, channels, height, width)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `keepdims=False`:\n 2D tensor with shape `(batch_size, channels)`.\n- If `keepdims=True`:\n - If `data_format=\"channels_last\"`:\n 4D tensor with shape `(batch_size, 1, 1, channels)`\n - If `data_format=\"channels_first\"`:\n 4D tensor with shape `(batch_size, channels, 1, 1)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(2, 4, 5, 3)\n>>> y = keras.layers.GlobalAveragePooling2D()(x)\n>>> y.shape\n(2, 3)"
- }
- ]
- },
- {
- "name": "GlobalMaxPooling1D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Global max pooling operation for temporal data.",
- "attributes": [
- {
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, steps, features)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, steps)`. It defaults to the `image_data_format`\n value found in your Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "name": "keepdims",
- "description": "A boolean, whether to keep the temporal dimension or not.\n If `keepdims` is `False` (default), the rank of the tensor is\n reduced for spatial dimensions. If `keepdims` is `True`, the\n temporal dimension are retained with length 1.\n The behavior is the same as for `tf.reduce_mean` or `np.mean`."
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format='channels_last'`:\n 3D tensor with shape:\n `(batch_size, steps, features)`\n- If `data_format='channels_first'`:\n 3D tensor with shape:\n `(batch_size, features, steps)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `keepdims=False`:\n 2D tensor with shape `(batch_size, features)`.\n- If `keepdims=True`:\n - If `data_format=\"channels_last\"`:\n 3D tensor with shape `(batch_size, 1, features)`\n - If `data_format=\"channels_first\"`:\n 3D tensor with shape `(batch_size, features, 1)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(2, 3, 4)\n>>> y = keras.layers.GlobalMaxPooling1D()(x)\n>>> y.shape\n(2, 4)"
- }
- ]
- },
- {
- "name": "GlobalMaxPooling2D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Global max pooling operation for 2D data.",
- "attributes": [
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, height, weight)`. It defaults to the\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json`. If you never set it, then it will be\n `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "name": "keepdims",
- "description": "A boolean, whether to keep the temporal dimension or not.\n If `keepdims` is `False` (default), the rank of the tensor is\n reduced for spatial dimensions. If `keepdims` is `True`, the\n spatial dimension are retained with length 1.\n The behavior is the same as for `tf.reduce_mean` or `np.mean`."
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format='channels_last'`:\n 4D tensor with shape:\n `(batch_size, height, width, channels)`\n- If `data_format='channels_first'`:\n 4D tensor with shape:\n `(batch_size, channels, height, width)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `keepdims=False`:\n 2D tensor with shape `(batch_size, channels)`.\n- If `keepdims=True`:\n - If `data_format=\"channels_last\"`:\n 4D tensor with shape `(batch_size, 1, 1, channels)`\n - If `data_format=\"channels_first\"`:\n 4D tensor with shape `(batch_size, channels, 1, 1)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(2, 4, 5, 3)\n>>> y = keras.layers.GlobalMaxPooling2D()(x)\n>>> y.shape\n(2, 3)"
- }
- ]
- },
- {
- "name": "GRU",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Gated Recurrent Unit - Cho et al. 2014.\n\nBased on available runtime hardware and constraints, this layer\nwill choose different implementations (cuDNN-based or backend-native)\nto maximize the performance. If a GPU is available and all\nthe arguments to the layer meet the requirement of the cuDNN kernel\n(see below for details), the layer will use a fast cuDNN implementation\nwhen using the TensorFlow backend.\n\nThe requirements to use the cuDNN implementation are:\n\n1. `activation` == `tanh`\n2. `recurrent_activation` == `sigmoid`\n3. `recurrent_dropout` == 0\n4. `unroll` is `False`\n5. `use_bias` is `True`\n6. `reset_after` is `True`\n7. Inputs, if use masking, are strictly right-padded.\n8. Eager execution is enabled in the outermost context.\n\nThere are two variants of the GRU implementation. The default one is based\non [v3](https://arxiv.org/abs/1406.1078v3) and has reset gate applied to\nhidden state before matrix multiplication. The other one is based on\n[original](https://arxiv.org/abs/1406.1078v1) and has the order reversed.\n\nThe second variant is compatible with CuDNNGRU (GPU-only) and allows\ninference on CPU. Thus it has separate biases for `kernel` and\n`recurrent_kernel`. To use this variant, set `reset_after=True` and\n`recurrent_activation='sigmoid'`.\n\nFor example:\n\n```\n>>> inputs = np.random.random((32, 10, 8))\n>>> gru = keras.layers.GRU(4)\n>>> output = gru(inputs)\n>>> output.shape\n(32, 4)\n>>> gru = keras.layers.GRU(4, return_sequences=True, return_state=True)\n>>> whole_sequence_output, final_state = gru(inputs)\n>>> whole_sequence_output.shape\n(32, 10, 4)\n>>> final_state.shape\n(32, 4)\n```",
- "attributes": [
- {
- "default": "tanh",
- "description": "Activation function to use.\n Default: hyperbolic tangent (`tanh`).\n If you pass `None`, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "default": "hard_sigmoid",
- "description": "Activation function to use\n for the recurrent step.\n Default: sigmoid (`sigmoid`).\n If you pass `None`, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "recurrent_activation"
- },
- {
- "default": true,
- "description": "Boolean, (default `True`), whether the layer\n should use a bias vector.",
- "name": "use_bias",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs. Default:\n `\"glorot_uniform\"`.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Orthogonal",
- "config": {
- "gain": 1,
- "seed": null
- }
- },
- "description": "Initializer for the `recurrent_kernel`\n weights matrix, used for the linear transformation of the recurrent\n state. Default: `\"orthogonal\"`.",
- "name": "recurrent_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the bias vector. Default: `\"zeros\"`.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop for the\n linear transformation of the inputs. Default: 0.",
- "name": "dropout"
- },
- {
- "default": 1,
- "description": "Implementation mode, either 1 or 2.\n Mode 1 will structure its operations as a larger number of\n smaller dot products and additions, whereas mode 2 will\n batch them into fewer, larger operations. These modes will\n have different performance profiles on different hardware and\n for different applications. Default: 2.",
- "name": "implementation"
- },
- {
- "default": false,
- "description": "Boolean. Whether to return the last output\n in the output sequence, or the full sequence. Default: `False`.",
- "name": "return_sequences"
- },
- {
- "default": false,
- "description": "Boolean. Whether to return the last state in addition\n to the output. Default: `False`.",
- "name": "return_state"
- },
- {
- "default": false,
- "description": "Boolean (default `False`).\n If `True`, process the input sequence backwards and return the\n reversed sequence.",
- "name": "go_backwards"
- },
- {
- "default": false,
- "description": "Boolean (default: `False`). If `True`, the last state\n for each sample at index i in a batch will be used as initial\n state for the sample of index i in the following batch.",
- "name": "stateful"
- },
- {
- "default": false,
- "description": "Boolean (default: `False`).\n If `True`, the network will be unrolled,\n else a symbolic loop will be used.\n Unrolling can speed-up a RNN,\n although it tends to be more memory-intensive.\n Unrolling is only suitable for short sequences.",
- "name": "unroll"
- },
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.\n Default: `None`.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the output of the\n layer (its \"activation\"). Default: `None`.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.\n Default: `None`.",
- "name": "bias_constraint"
- },
- {
- "description": "Float between 0 and 1. Fraction of the units to drop\n for the linear transformation of the recurrent state. Default: 0.",
- "name": "recurrent_dropout"
- },
- {
- "description": "`None`.",
- "name": "Default"
- },
- {
- "description": "GRU convention (whether to apply reset gate after or\n before matrix multiplication). `False` is `\"before\"`,\n `True` is `\"after\"` (default and cuDNN compatible).",
- "name": "reset_after"
- },
- {
- "description": "The shape format of the `inputs` and `outputs` tensors.\n If True, the inputs and outputs will be in shape\n `[timesteps, batch, feature]`, whereas in the False case, it will be\n `[batch, timesteps, feature]`. Using `time_major = True` is a bit more\n efficient because it avoids transposes at the beginning and end of the\n RNN calculation. However, most TensorFlow data is batch-major, so by\n default this function accepts input and emits output in batch-major\n form.",
- "name": "time_major"
- },
- {
- "name": "seed",
- "description": "Random seed for dropout."
- },
- {
- "name": "use_cudnn",
- "description": "Whether to use a cuDNN-backed implementation. `\"auto\"` will\n attempt to use cuDNN when feasible, and will fallback to the\n default implementation if not."
- }
- ],
- "inputs": [
- {
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "recurrent_kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation](https://arxiv.org/abs/1406.1078)"
- },
- {
- "description": "[On the Properties of Neural Machine Translation: Encoder-Decoder Approaches](https://arxiv.org/abs/1409.1259)"
- },
- {
- "description": "[Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling](https://arxiv.org/abs/1412.3555v1)"
- },
- {
- "description": "[A Theoretically Grounded Application of Dropout in Recurrent Neural Networks](https://arxiv.org/abs/1512.05287)"
- }
- ]
- },
- {
- "name": "GRUCell",
- "module": "keras.layers",
- "description": "Cell class for the GRU layer.\n\nThis class processes one step within the whole time sequence input, whereas\n`keras.layer.GRU` processes the whole sequence.",
- "attributes": [
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "description": "Activation function to use. Default: hyperbolic tangent\n (`tanh`). If you pass None, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "description": "Activation function to use for the recurrent step.\n Default: sigmoid (`sigmoid`). If you pass `None`, no activation is\n applied (ie. \"linear\" activation: `a(x) = x`).",
- "name": "recurrent_activation"
- },
- {
- "default": true,
- "description": "Boolean, (default `True`), whether the layer\n should use a bias vector.",
- "name": "use_bias",
- "visible": false
- },
- {
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs. Default:\n `\"glorot_uniform\"`.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the `recurrent_kernel`\n weights matrix, used for the linear transformation\n of the recurrent state. Default: `\"orthogonal\"`.",
- "name": "recurrent_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector. Default: `\"zeros\"`.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.\n Default: `None`.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.\n Default: `None`.",
- "name": "bias_constraint"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop for the\n linear transformation of the inputs. Default: 0.",
- "name": "dropout"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop\n for the linear transformation of the recurrent state. Default: 0.",
- "name": "recurrent_dropout"
- },
- {
- "description": "Implementation mode, either 1 or 2.\n Mode 1 will structure its operations as a larger number of\n smaller dot products and additions, whereas mode 2 (default) will\n batch them into fewer, larger operations. These modes will\n have different performance profiles on different hardware and\n for different applications. Default: 2.",
- "name": "implementation"
- },
- {
- "description": "`None`.",
- "name": "Default"
- },
- {
- "description": "GRU convention (whether to apply reset gate after or\n before matrix multiplication). False = \"before\",\n True = \"after\" (default and cuDNN compatible).",
- "name": "reset_after"
- },
- {
- "name": "seed",
- "description": "Random seed for dropout."
- }
- ],
- "examples": [
- {
- "code": ">>> inputs = np.random.random((32, 10, 8))\n>>> rnn = keras.layers.RNN(keras.layers.GRUCell(4))\n>>> output = rnn(inputs)\n>>> output.shape\n(32, 4)\n>>> rnn = keras.layers.RNN(\n... keras.layers.GRUCell(4),\n... return_sequences=True,\n... return_state=True)\n>>> whole_sequence_output, final_state = rnn(inputs)\n>>> whole_sequence_output.shape\n(32, 10, 4)\n>>> final_state.shape\n(32, 4)"
- }
- ]
- },
- {
- "name": "HardSigmoid",
- "category": "Activation"
- },
- {
- "name": "InputLayer",
- "module": "keras.layers",
- "category": "Data",
- "description": "Layer to be used as an entry point into a Network (a graph of layers).\n\nIt can either wrap an existing tensor (pass an `input_tensor` argument)\nor create a placeholder tensor (pass arguments `input_shape`, and\noptionally, `dtype`).\n\nIt is generally recommend to use the Keras Functional model via `Input`,\n(which creates an `InputLayer`) without directly using `InputLayer`.\n\nWhen using `InputLayer` with the Keras Sequential model, it can be skipped\nby moving the `input_shape` parameter to the first layer after the\n`InputLayer`.\n\nThis class can create placeholders for `tf.Tensors`, `tf.SparseTensors`, and\n`tf.RaggedTensors` by choosing `sparse=True` or `ragged=True`. Note that\n`sparse` and `ragged` can't be configured to `True` at the same time.",
- "attributes": [
- {
- "description": "Shape tuple (not including the batch axis), or\n `TensorShape` instance (not including the batch axis).",
- "name": "input_shape"
- },
- {
- "description": "Optional input batch size (integer or `None`).",
- "name": "batch_size"
- },
- {
- "description": "Optional datatype of the input. When not provided, the Keras\n default `float` type will be used.",
- "name": "dtype"
- },
- {
- "description": "Optional tensor to use as layer input. If set, the layer\n will use the `tf.TypeSpec` of this tensor rather\n than creating a new placeholder tensor.",
- "name": "input_tensor"
- },
- {
- "description": "Boolean, whether the placeholder created is meant to be sparse.\n Defaults to `False`.",
- "name": "sparse"
- },
- {
- "description": "Boolean, whether the placeholder created is meant to be ragged.\n In this case, values of `None` in the `shape` argument represent\n ragged dimensions. For more information about `tf.RaggedTensor`, see\n [this guide](https://www.tensorflow.org/guide/ragged_tensor).\n Defaults to `False`.",
- "name": "ragged"
- },
- {
- "description": "Optional name of the layer (string).",
- "name": "name"
- },
- {
- "description": "A `tf.TypeSpec` object to create Input from. This\n `tf.TypeSpec` represents the entire batch. When provided, all other\n args except name must be `None`.",
- "name": "type_spec"
- }
- ],
- "examples": [
- {
- "code": "# With explicit InputLayer.\nmodel = tf.keras.Sequential([\n tf.keras.layers.InputLayer(input_shape=(4,)),\n tf.keras.layers.Dense(8)])\nmodel.compile(tf.keras.optimizers.RMSprop(0.001), loss='mse')\nmodel.fit(np.zeros((10, 4)),\n np.ones((10, 8)))\n\n# Without InputLayer and let the first layer to have the input_shape.\n# Keras will add a input for the model behind the scene.\nmodel = tf.keras.Sequential([\n tf.keras.layers.Dense(8, input_shape=(4,))])\nmodel.compile(tf.keras.optimizers.RMSprop(0.001), loss='mse')\nmodel.fit(np.zeros((10, 4)),\n np.ones((10, 8)))"
- }
- ]
- },
- {
- "name": "InputSpec",
- "module": "keras.layers",
- "category": "Data",
- "description": "Specifies the rank, dtype and shape of every input to a layer.\n\nLayers can expose (if appropriate) an `input_spec` attribute:\nan instance of `InputSpec`, or a nested structure of `InputSpec` instances\n(one per input tensor). These objects enable the layer to run input\ncompatibility checks for input structure, input rank, input shape, and\ninput dtype for the first argument of `Layer.__call__`.\n\nA `None` entry in a shape is compatible with any dimension.",
- "attributes": [
- {
- "description": "Expected dtype of the input.",
- "name": "dtype"
- },
- {
- "description": "Shape tuple, expected shape of the input\n (may include `None` for dynamic axes).\n Includes the batch size.",
- "name": "shape"
- },
- {
- "description": "Integer, expected rank of the input.",
- "name": "ndim"
- },
- {
- "description": "Integer, maximum rank of the input.",
- "name": "max_ndim"
- },
- {
- "description": "Integer, minimum rank of the input.",
- "name": "min_ndim"
- },
- {
- "description": "Dictionary mapping integer axes to\n a specific dimension value.",
- "name": "axes"
- },
- {
- "description": "If `True`, allow inputs of rank N+1 as long\n as the last axis of the input is 1, as well as inputs of rank N-1\n as long as the last axis of the spec is 1.",
- "name": "allow_last_axis_squeeze"
- },
- {
- "description": "Expected key corresponding to this input when passing data as\n a dictionary.",
- "name": "name"
- },
- {
- "name": "optional",
- "description": "Boolean, whether the input is optional or not.\n An optional input can accept `None` values."
- }
- ],
- "examples": [
- {
- "code": "class MyLayer(Layer):\n def __init__(self):\n super().__init__()\n # The layer will accept inputs with\n # shape (*, 28, 28) & (*, 28, 28, 1)\n # and raise an appropriate error message otherwise.\n self.input_spec = InputSpec(\n shape=(None, 28, 28, 1),\n allow_last_axis_squeeze=True)"
- }
- ]
- },
- {
- "name": "Lambda",
- "module": "keras.layers",
- "description": "Wraps arbitrary expressions as a `Layer` object.\n\nThe `Lambda` layer exists so that arbitrary expressions can be used\nas a `Layer` when constructing Sequential\nand Functional API models. `Lambda` layers are best suited for simple\noperations or quick experimentation. For more advanced use cases,\nprefer writing new subclasses of `Layer`.\n\nWARNING: `Lambda` layers have (de)serialization limitations!\n\nThe main reason to subclass `Layer` instead of using a\n`Lambda` layer is saving and inspecting a model. `Lambda` layers\nare saved by serializing the Python bytecode, which is fundamentally\nnon-portable and potentially unsafe.\nThey should only be loaded in the same environment where\nthey were saved. Subclassed layers can be saved in a more portable way\nby overriding their `get_config()` method. Models that rely on\nsubclassed Layers are also often easier to visualize and reason about.",
- "attributes": [
- {
- "description": "The function to be evaluated. Takes input tensor as first\n argument.",
- "name": "function"
- },
- {
- "description": "Expected output shape from function. This argument\n can usually be inferred if not explicitly provided.\n Can be a tuple or function. If a tuple, it only specifies\n the first dimension onward; sample dimension is assumed\n either the same as the input:\n `output_shape = (input_shape[0], ) + output_shape` or,\n the input is `None` and the sample dimension is also `None`:\n `output_shape = (None, ) + output_shape`.\n If a function, it specifies the\n entire shape as a function of the input shape:\n `output_shape = f(input_shape)`.",
- "name": "output_shape"
- },
- {
- "description": "Optional dictionary of keyword arguments to be passed to the\n function.",
- "name": "arguments"
- },
- {
- "description": "Either None (indicating no masking) or a callable with the same\n signature as the `compute_mask` layer method, or a tensor\n that will be returned as output mask regardless\n of what the input is.",
- "name": "mask"
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument input_shape (tuple of\nintegers, does not include the samples axis) when using this layer as the\nfirst layer in a model.",
- "name": "inputs",
- "list": true
- }
- ],
- "outputs": [
- {
- "description": "Specified by `output_shape` argument",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "# add a x -> x^2 layer\nmodel.add(Lambda(lambda x: x ** 2))"
- }
- ]
- },
- {
- "name": "LeakyReLU",
- "module": "keras.layers",
- "category": "Activation",
- "description": "Leaky version of a Rectified Linear Unit activation layer.\n\nThis layer allows a small gradient when the unit is not active.\n\nFormula:\n\n``` python\nf(x) = alpha * x if x < 0\nf(x) = x if x >= 0\n```",
- "attributes": [
- {
- "description": "Float >= `0.`. Negative slope coefficient. Defaults to `0.3`.",
- "name": "alpha"
- },
- {
- "name": "negative_slope",
- "description": "Float >= 0.0. Negative slope coefficient.\n Defaults to `0.3`."
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments, such as\n `name` and `dtype`."
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the batch axis)\nwhen using this layer as the first layer in a model.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as the input.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Rectifier Nonlinearities Improve Neural Network Acoustic Models]( https://ai.stanford.edu/~amaas/papers/relu_hybrid_icml2013_final.pdf)"
- }
- ],
- "examples": [
- {
- "code": "leaky_relu_layer = LeakyReLU(negative_slope=0.5)\ninput = np.array([-10, -5, 0.0, 5, 10])\nresult = leaky_relu_layer(input)\n# result = [-5. , -2.5, 0. , 5. , 10.]"
- }
- ]
- },
- {
- "name": "LocallyConnected1D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Locally-connected layer for 1D inputs.\n\nThe `LocallyConnected1D` layer works similarly to\nthe `Conv1D` layer, except that weights are unshared,\nthat is, a different set of filters is applied at each different patch\nof the input.\n\nNote: layer attributes cannot be modified after the layer has been called\nonce (except the `trainable` attribute).",
- "attributes": [
- {
- "description": "Integer, the dimensionality of the output space (i.e. the\n number of output filters in the convolution).",
- "name": "filters"
- },
- {
- "description": "An integer or tuple/list of a single integer, specifying\n the length of the 1D convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "An integer or tuple/list of a single integer, specifying the\n stride length of the convolution.",
- "name": "strides"
- },
- {
- "description": "Currently only supports `\"valid\"` (case-insensitive). `\"same\"`\n may be supported in the future. `\"valid\"` means no padding.",
- "name": "padding"
- },
- {
- "description": "Activation function to use. If you don't specify anything,\n no activation is applied (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "description": "Boolean, whether the layer uses a bias vector.",
- "name": "use_bias"
- },
- {
- "description": "Initializer for the `kernel` weights matrix.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the output of the\n layer (its \"activation\")..",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to the kernel matrix.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.",
- "name": "bias_constraint"
- },
- {
- "default": "channels_last",
- "description": "A string, one of `channels_last` (default) or\n `channels_first`. The ordering of the dimensions in the inputs.\n `channels_last` corresponds to inputs with shape `(batch, length,\n channels)` while `channels_first` corresponds to inputs with shape\n `(batch, channels, length)`. When unspecified, uses\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json` (if exists) else 'channels_last'.\n Defaults to 'channels_last'.",
- "name": "data_format"
- },
- {
- "description": "implementation mode, either `1`, `2`, or `3`. `1` loops\n over input spatial locations to perform the forward pass. It is\n memory-efficient but performs a lot of (small) ops. `2` stores layer\n weights in a dense but sparsely-populated 2D matrix and implements the\n forward pass as a single matrix-multiply. It uses a lot of RAM but\n performs few (large) ops. `3` stores layer weights in a sparse tensor\n and implements the forward pass as a single sparse matrix-multiply.\n How to choose:\n `1`: large, dense models,\n `2`: small models,\n `3`: large, sparse models, where \"large\" stands for large\n input/output activations (i.e. many `filters`, `input_filters`,\n large `input_size`, `output_size`), and \"sparse\" stands for few\n connections between inputs and outputs, i.e. small ratio\n `filters * input_filters * kernel_size / (input_size * strides)`,\n where inputs to and outputs of the layer are assumed to have\n shapes `(input_size, input_filters)`, `(output_size, filters)`\n respectively. It is recommended to benchmark each in the setting\n of interest to pick the most efficient one (in terms of speed and\n memory usage). Correct choice of implementation can lead to\n dramatic speed improvements (e.g. 50X), potentially at the expense\n of RAM. Also, only `padding=\"valid\"` is supported by\n `implementation=1`.",
- "name": "implementation"
- }
- ],
- "inputs": [
- {
- "description": "3D tensor with shape: `(batch_size, steps, input_dim)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "3D tensor with shape: `(batch_size, new_steps, filters)` `steps` value\n might have changed due to padding or strides.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": " # apply a unshared weight convolution 1d of length 3 to a sequence with\n # 10 timesteps, with 64 output filters\n model = Sequential()\n model.add(LocallyConnected1D(64, 3, input_shape=(10, 32)))\n # now model.output_shape == (None, 8, 64)\n # add a new conv1d on top\n model.add(LocallyConnected1D(32, 3))\n # now model.output_shape == (None, 6, 32)"
- }
- ]
- },
- {
- "name": "LocallyConnected2D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Locally-connected layer for 2D inputs.\n\nThe `LocallyConnected2D` layer works similarly\nto the `Conv2D` layer, except that weights are unshared,\nthat is, a different set of filters is applied at each\ndifferent patch of the input.\n\nNote: layer attributes cannot be modified after the layer has been called\nonce (except the `trainable` attribute).",
- "attributes": [
- {
- "description": "Integer, the dimensionality of the output space (i.e. the\n number of output filters in the convolution).",
- "name": "filters"
- },
- {
- "description": "An integer or tuple/list of 2 integers, specifying the\n width and height of the 2D convolution window. Can be a single integer\n to specify the same value for all spatial dimensions.",
- "name": "kernel_size"
- },
- {
- "description": "An integer or tuple/list of 2 integers, specifying the strides\n of the convolution along the width and height. Can be a single integer\n to specify the same value for all spatial dimensions.",
- "name": "strides"
- },
- {
- "description": "Currently only support `\"valid\"` (case-insensitive). `\"same\"`\n will be supported in future. `\"valid\"` means no padding.",
- "name": "padding"
- },
- {
- "default": "channels_last",
- "description": "A string, one of `channels_last` (default) or\n `channels_first`. The ordering of the dimensions in the inputs.\n `channels_last` corresponds to inputs with shape `(batch, height,\n width, channels)` while `channels_first` corresponds to inputs with\n shape\n `(batch, channels, height, width)`. When unspecified, uses\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json` (if exists) else 'channels_last'.\n Defaults to 'channels_last'.",
- "name": "data_format"
- },
- {
- "description": "Activation function to use. If you don't specify anything,\n no activation is applied (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "description": "Boolean, whether the layer uses a bias vector.",
- "name": "use_bias",
- "visible": false
- },
- {
- "description": "Initializer for the `kernel` weights matrix.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the output of the\n layer (its \"activation\").",
- "name": "activity_regularizer"
- },
- {
- "description": "Constraint function applied to the kernel matrix.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.",
- "name": "bias_constraint"
- },
- {
- "description": "implementation mode, either `1`, `2`, or `3`. `1` loops\n over input spatial locations to perform the forward pass. It is\n memory-efficient but performs a lot of (small) ops. `2` stores layer\n weights in a dense but sparsely-populated 2D matrix and implements the\n forward pass as a single matrix-multiply. It uses a lot of RAM but\n performs few (large) ops. `3` stores layer weights in a sparse tensor\n and implements the forward pass as a single sparse matrix-multiply.\n How to choose:\n `1`: large, dense models,\n `2`: small models,\n `3`: large, sparse models, where \"large\" stands for large\n input/output activations (i.e. many `filters`, `input_filters`,\n large `np.prod(input_size)`, `np.prod(output_size)`), and \"sparse\"\n stands for few connections between inputs and outputs, i.e. small\n ratio `filters * input_filters * np.prod(kernel_size) /\n (np.prod(input_size) * np.prod(strides))`, where inputs to and\n outputs of the layer are assumed to have shapes `input_size +\n (input_filters,)`, `output_size + (filters,)` respectively. It is\n recommended to benchmark each in the setting of interest to pick\n the most efficient one (in terms of speed and memory usage).\n Correct choice of implementation can lead to dramatic speed\n improvements (e.g. 50X), potentially at the expense of RAM. Also,\n only `padding=\"valid\"` is supported by `implementation=1`.",
- "name": "implementation"
- }
- ],
- "inputs": [
- {
- "description": "4D tensor with shape: `(samples, channels, rows, cols)` if\n data_format='channels_first'\nor 4D tensor with shape: `(samples, rows, cols, channels)` if\n data_format='channels_last'.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "4D tensor with shape: `(samples, filters, new_rows, new_cols)` if\n data_format='channels_first'\nor 4D tensor with shape: `(samples, new_rows, new_cols, filters)` if\n data_format='channels_last'. `rows` and `cols` values might have\n changed due to padding.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": " # apply a 3x3 unshared weights convolution with 64 output filters on a\n 32x32 image\n # with `data_format=\"channels_last\"`:\n model = Sequential()\n model.add(LocallyConnected2D(64, (3, 3), input_shape=(32, 32, 3)))\n # now model.output_shape == (None, 30, 30, 64)\n # notice that this layer will consume (30*30)*(3*3*3*64) + (30*30)*64\n parameters\n\n # add a 3x3 unshared weights convolution on top, with 32 output filters:\n model.add(LocallyConnected2D(32, (3, 3)))\n # now model.output_shape == (None, 28, 28, 32)"
- }
- ]
- },
- {
- "name": "LSTM",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Long Short-Term Memory layer - Hochreiter 1997.\n\nBased on available runtime hardware and constraints, this layer\nwill choose different implementations (cuDNN-based or backend-native)\nto maximize the performance. If a GPU is available and all\nthe arguments to the layer meet the requirement of the cuDNN kernel\n(see below for details), the layer will use a fast cuDNN implementation\nwhen using the TensorFlow backend.\nThe requirements to use the cuDNN implementation are:\n\n1. `activation` == `tanh`\n2. `recurrent_activation` == `sigmoid`\n3. `recurrent_dropout` == 0\n4. `unroll` is `False`\n5. `use_bias` is `True`\n6. Inputs, if use masking, are strictly right-padded.\n7. Eager execution is enabled in the outermost context.\n\nFor example:\n\n```\n>>> inputs = np.random.random((32, 10, 8))\n>>> lstm = keras.layers.LSTM(4)\n>>> output = lstm(inputs)\n>>> output.shape\n(32, 4)\n>>> lstm = keras.layers.LSTM(\n... 4, return_sequences=True, return_state=True)\n>>> whole_seq_output, final_memory_state, final_carry_state = lstm(inputs)\n>>> whole_seq_output.shape\n(32, 10, 4)\n>>> final_memory_state.shape\n(32, 4)\n>>> final_carry_state.shape\n(32, 4)\n```",
- "attributes": [
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "default": "tanh",
- "description": "Activation function to use.\n Default: hyperbolic tangent (`tanh`).\n If you pass `None`, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "default": "hard_sigmoid",
- "description": "Activation function to use\n for the recurrent step.\n Default: sigmoid (`sigmoid`).\n If you pass `None`, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "recurrent_activation"
- },
- {
- "description": "Boolean, (default `True`), whether the layer\n should use a bias vector.",
- "name": "use_bias",
- "visible": false
- },
- {
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs. Default:\n `\"glorot_uniform\"`.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the `recurrent_kernel`\n weights matrix, used for the linear transformation of the recurrent\n state. Default: `\"orthogonal\"`.",
- "name": "recurrent_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector. Default: `\"zeros\"`.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": true,
- "description": "Boolean (default `True`). If `True`,\n add 1 to the bias of the forget gate at initialization.\n Setting it to `True` will also force `bias_initializer=\"zeros\"`.\n This is recommended in [Jozefowicz et al.](\n https://github.com/mlresearch/v37/blob/gh-pages/jozefowicz15.pdf)",
- "name": "unit_forget_bias"
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.\n Default: `None`.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the output of the\n layer (its \"activation\"). Default: `None`.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_constraint",
- "visible": false
- },
- {
- "description": "Constraint function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_constraint",
- "visible": false
- },
- {
- "description": "Constraint function applied to the bias vector.\n Default: `None`.",
- "name": "bias_constraint",
- "visible": false
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop for the\n linear transformation of the inputs. Default: 0.",
- "name": "dropout"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop\n for the linear transformation of the recurrent state. Default: 0.",
- "name": "recurrent_dropout"
- },
- {
- "default": 1,
- "description": "Implementation mode, either 1 or 2. Mode 1 will structure\n its operations as a larger number of smaller dot products and additions,\n whereas mode 2 will batch them into fewer, larger operations. These modes\n will have different performance profiles on different hardware and for\n different applications. Default: 2.",
- "name": "implementation"
- },
- {
- "default": false,
- "description": "Boolean. Whether to return the last output\n in the output sequence, or the full sequence. Default: `False`.",
- "name": "return_sequences"
- },
- {
- "default": false,
- "description": "Boolean. Whether to return the last state in addition\n to the output. Default: `False`.",
- "name": "return_state"
- },
- {
- "default": false,
- "description": "Boolean (default: `False`).\n If `True`, process the input sequence backwards and return the\n reversed sequence.",
- "name": "go_backwards"
- },
- {
- "default": false,
- "description": "Boolean (default: `False`). If `True`, the last state\n for each sample at index i in a batch will be used as initial\n state for the sample of index i in the following batch.",
- "name": "stateful"
- },
- {
- "default": false,
- "description": "Boolean (default False).\n If `True`, the network will be unrolled,\n else a symbolic loop will be used.\n Unrolling can speed-up a RNN,\n although it tends to be more memory-intensive.\n Unrolling is only suitable for short sequences.",
- "name": "unroll"
- },
- {
- "description": "`None`.",
- "name": "Default"
- },
- {
- "description": "The shape format of the `inputs` and `outputs` tensors.\n If True, the inputs and outputs will be in shape\n `[timesteps, batch, feature]`, whereas in the False case, it will be\n `[batch, timesteps, feature]`. Using `time_major = True` is a bit more\n efficient because it avoids transposes at the beginning and end of the\n RNN calculation. However, most TensorFlow data is batch-major, so by\n default this function accepts input and emits output in batch-major\n form.",
- "name": "time_major"
- },
- {
- "name": "seed",
- "description": "Random seed for dropout."
- },
- {
- "name": "use_cudnn",
- "description": "Whether to use a cuDNN-backed implementation. `\"auto\"` will\n attempt to use cuDNN when feasible, and will fallback to the\n default implementation if not."
- }
- ],
- "inputs": [
- {
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "recurrent_kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Long short-term memory](http://www.bioinf.jku.at/publications/older/2604.pdf)"
- },
- {
- "description": "[Learning to forget: Continual prediction with LSTM](http://www.mitpressjournals.org/doi/pdf/10.1162/089976600300015015)"
- },
- {
- "description": "[Supervised sequence labeling with recurrent neural networks](http://www.cs.toronto.edu/~graves/preprint.pdf)"
- },
- {
- "description": "[A Theoretically Grounded Application of Dropout in Recurrent Neural Networks](https://arxiv.org/abs/1512.05287)"
- }
- ]
- },
- {
- "name": "LSTMCell",
- "module": "keras.layers",
- "description": "Cell class for the LSTM layer.\n\nThis class processes one step within the whole time sequence input, whereas\n`keras.layer.LSTM` processes the whole sequence.",
- "attributes": [
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "description": "Activation function to use. Default: hyperbolic tangent\n (`tanh`). If you pass None, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "description": "Activation function to use for the recurrent step.\n Default: sigmoid (`sigmoid`). If you pass `None`, no activation is\n applied (ie. \"linear\" activation: `a(x) = x`).",
- "name": "recurrent_activation"
- },
- {
- "default": true,
- "description": "Boolean, (default `True`), whether the layer\n should use a bias vector.",
- "name": "use_bias"
- },
- {
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs. Default:\n `\"glorot_uniform\"`.",
- "name": "kernel_initializer"
- },
- {
- "description": "Initializer for the `recurrent_kernel`\n weights matrix, used for the linear transformation\n of the recurrent state. Default: `\"orthogonal\"`.",
- "name": "recurrent_initializer"
- },
- {
- "description": "Initializer for the bias vector. Default: `\"zeros\"`.",
- "name": "bias_initializer"
- },
- {
- "description": "Boolean (default `True`). If `True`,\n add 1 to the bias of the forget gate at initialization.\n Setting it to `True` will also force `bias_initializer=\"zeros\"`.\n This is recommended in [Jozefowicz et al.](\n https://github.com/mlresearch/v37/blob/gh-pages/jozefowicz15.pdf)",
- "name": "unit_forget_bias"
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_regularizer"
- },
- {
- "description": "Regularizer function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_regularizer"
- },
- {
- "description": "Regularizer function applied to the bias vector.\n Default: `None`.",
- "name": "bias_regularizer"
- },
- {
- "description": "Constraint function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.\n Default: `None`.",
- "name": "bias_constraint"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop for the\n linear transformation of the inputs. Default: 0.",
- "name": "dropout"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop\n for the linear transformation of the recurrent state. Default: 0.",
- "name": "recurrent_dropout"
- },
- {
- "description": "Implementation mode, either 1 or 2.\n Mode 1 will structure its operations as a larger number of smaller dot\n products and additions, whereas mode 2 (default) will batch them into\n fewer, larger operations. These modes will have different performance\n profiles on different hardware and for different applications. Default: 2.",
- "name": "implementation"
- },
- {
- "description": "`None`.",
- "name": "Default"
- },
- {
- "name": "seed",
- "description": "Random seed for dropout."
- }
- ],
- "examples": [
- {
- "code": ">>> inputs = np.random.random((32, 10, 8))\n>>> rnn = keras.layers.RNN(keras.layers.LSTMCell(4))\n>>> output = rnn(inputs)\n>>> output.shape\n(32, 4)\n>>> rnn = keras.layers.RNN(\n... keras.layers.LSTMCell(4),\n... return_sequences=True,\n... return_state=True)\n>>> whole_sequence_output, final_state = rnn(inputs)\n>>> whole_sequence_output.shape\n(32, 10, 4)\n>>> final_state.shape\n(32, 4)"
- }
- ]
- },
- {
- "name": "Masking",
- "module": "keras.layers",
- "description": "Masks a sequence by using a mask value to skip timesteps.\n\nFor each timestep in the input tensor (dimension #1 in the tensor),\nif all values in the input tensor at that timestep\nare equal to `mask_value`, then the timestep will be masked (skipped)\nin all downstream layers (as long as they support masking).\n\nIf any downstream layer does not support masking yet receives such\nan input mask, an exception will be raised.",
- "attributes": [
- {
- "description": "Either None or mask value to skip\n",
- "name": "mask_value"
- }
- ],
- "examples": [
- {
- "summary": "Consider a NumPy data array `x` of shape `(samples, timesteps, features)`,\nto be fed to an LSTM layer. You want to mask timestep #3 and #5 because you\nlack data for these timesteps. You can:\n- Set `x[:, 3, :] = 0.` and `x[:, 5, :] = 0.`\n- Insert a `Masking` layer with `mask_value=0.` before the LSTM layer:",
- "code": "samples, timesteps, features = 32, 10, 8\ninputs = np.random.random([samples, timesteps, features]).astype(np.float32)\ninputs[:, 3, :] = 0.\ninputs[:, 5, :] = 0.\n\nmodel = keras.models.Sequential()\nmodel.add(keras.layers.Masking(mask_value=0.0))\nmodel.add(keras.layers.LSTM(32))\noutput = model(inputs)\n# The time step 3 and 5 will be skipped from LSTM calculation."
- }
- ]
- },
- {
- "name": "Maximum",
- "module": "keras.layers",
- "category": "Tensor",
- "description": "Computes element-wise maximum on a list of inputs.\n\nIt takes as input a list of tensors, all of the same shape,\nand returns a single tensor (also of the same shape).",
- "inputs": [
- {
- "name": "inputs",
- "list": true
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 3, 4)\n>>> x1 = np.random.rand(*input_shape)\n>>> x2 = np.random.rand(*input_shape)\n>>> y = keras.layers.Maximum()([x1, x2])"
- },
- {
- "summary": "Usage in a Keras model:",
- "code": ">>> input1 = keras.layers.Input(shape=(16,))\n>>> x1 = keras.layers.Dense(8, activation='relu')(input1)\n>>> input2 = keras.layers.Input(shape=(32,))\n>>> x2 = keras.layers.Dense(8, activation='relu')(input2)\n>>> # equivalent to `y = keras.layers.maximum([x1, x2])`\n>>> y = keras.layers.Maximum()([x1, x2])\n>>> out = keras.layers.Dense(4)(y)\n>>> model = keras.models.Model(inputs=[input1, input2], outputs=out)"
- }
- ]
- },
- {
- "name": "MaxPooling1D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Max pooling operation for 1D temporal data.\n\nDownsamples the input representation by taking the maximum value over a\nspatial window of size `pool_size`. The window is shifted by `strides`.\n\nThe resulting output when using the `\"valid\"` padding option has a shape of:\n`output_shape = (input_shape - pool_size + 1) / strides)`.\n\nThe resulting output shape when using the `\"same\"` padding option is:\n`output_shape = input_shape / strides`",
- "attributes": [
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, steps, features)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, steps)`. It defaults to the `image_data_format`\n value found in your Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "default": "valid",
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input such that output has the same\n height/width dimension as the input.",
- "name": "padding"
- },
- {
- "default": [
- 2,
- 2
- ],
- "description": "int, size of the max pooling window.",
- "name": "pool_size"
- },
- {
- "default": [
- 2,
- 2
- ],
- "description": "int or None. Specifies how much the pooling window moves\n for each pooling step. If None, it will default to `pool_size`.",
- "name": "strides"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 3D tensor with shape `(batch_size, steps, features)`.\n- If `data_format=\"channels_first\"`:\n 3D tensor with shape `(batch_size, features, steps)`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 3D tensor with shape `(batch_size, downsampled_steps, features)`.\n- If `data_format=\"channels_first\"`:\n 3D tensor with shape `(batch_size, features, downsampled_steps)`.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "summary": "`strides=1` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([1., 2., 3., 4., 5.])\n>>> x = np.reshape(x, [1, 5, 1])\n>>> max_pool_1d = keras.layers.MaxPooling1D(pool_size=2,\n... strides=1, padding=\"valid\")\n>>> max_pool_1d(x)"
- },
- {
- "summary": "`strides=2` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([1., 2., 3., 4., 5.])\n>>> x = np.reshape(x, [1, 5, 1])\n>>> max_pool_1d = keras.layers.MaxPooling1D(pool_size=2,\n... strides=2, padding=\"valid\")\n>>> max_pool_1d(x)"
- },
- {
- "summary": "`strides=1` and `padding=\"same\"`:",
- "code": ">>> x = np.array([1., 2., 3., 4., 5.])\n>>> x = np.reshape(x, [1, 5, 1])\n>>> max_pool_1d = keras.layers.MaxPooling1D(pool_size=2,\n... strides=1, padding=\"same\")\n>>> max_pool_1d(x)"
- }
- ]
- },
- {
- "name": "MaxPooling2D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Max pooling operation for 2D spatial data.\n\nDownsamples the input along its spatial dimensions (height and width)\nby taking the maximum value over an input window\n(of size defined by `pool_size`) for each channel of the input.\nThe window is shifted by `strides` along each dimension.\n\nThe resulting output when using the `\"valid\"` padding option has a spatial\nshape (number of rows or columns) of:\n`output_shape = math.floor((input_shape - pool_size) / strides) + 1`\n(when `input_shape >= pool_size`)\n\nThe resulting output shape when using the `\"same\"` padding option is:\n`output_shape = math.floor((input_shape - 1) / strides) + 1`",
- "attributes": [
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, channels, height, width)`. It defaults to the\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json`. If you never set it, then it will be\n `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "default": "valid",
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input such that output has the same\n height/width dimension as the input.",
- "name": "padding"
- },
- {
- "default": [
- 2,
- 2
- ],
- "description": "int or tuple of 2 integers, factors by which to downscale\n (dim1, dim2). If only one integer is specified, the same\n window length will be used for all dimensions.",
- "name": "pool_size"
- },
- {
- "default": [
- 2,
- 2
- ],
- "description": "int or tuple of 2 integers, or None. Strides values. If None,\n it will default to `pool_size`. If only one int is specified, the\n same stride size will be used for all dimensions.",
- "name": "strides"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 4D tensor with shape `(batch_size, height, width, channels)`.\n- If `data_format=\"channels_first\"`:\n 4D tensor with shape `(batch_size, channels, height, width)`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 4D tensor with shape\n `(batch_size, pooled_height, pooled_width, channels)`.\n- If `data_format=\"channels_first\"`:\n 4D tensor with shape\n `(batch_size, channels, pooled_height, pooled_width)`.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "summary": "`strides=(1, 1)` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([[1., 2., 3.],\n... [4., 5., 6.],\n... [7., 8., 9.]])\n>>> x = np.reshape(x, [1, 3, 3, 1])\n>>> max_pool_2d = keras.layers.MaxPooling2D(pool_size=(2, 2),\n... strides=(1, 1), padding=\"valid\")\n>>> max_pool_2d(x)"
- },
- {
- "summary": "`strides=(2, 2)` and `padding=\"valid\"`:",
- "code": ">>> x = np.array([[1., 2., 3., 4.],\n... [5., 6., 7., 8.],\n... [9., 10., 11., 12.]])\n>>> x = np.reshape(x, [1, 3, 4, 1])\n>>> max_pool_2d = keras.layers.MaxPooling2D(pool_size=(2, 2),\n... strides=(2, 2), padding=\"valid\")\n>>> max_pool_2d(x)"
- },
- {
- "summary": "`stride=(1, 1)` and `padding=\"same\"`:",
- "code": ">>> x = np.array([[1., 2., 3.],\n... [4., 5., 6.],\n... [7., 8., 9.]])\n>>> x = np.reshape(x, [1, 3, 3, 1])\n>>> max_pool_2d = keras.layers.MaxPooling2D(pool_size=(2, 2),\n... strides=(1, 1), padding=\"same\")\n>>> max_pool_2d(x)"
- }
- ]
- },
- {
- "name": "MaxPooling3D",
- "module": "keras.layers",
- "category": "Pool",
- "description": "Max pooling operation for 3D data (spatial or spatio-temporal).\n\nDownsamples the input along its spatial dimensions (depth, height, and\nwidth) by taking the maximum value over an input window (of size defined by\n`pool_size`) for each channel of the input. The window is shifted by\n`strides` along each dimension.",
- "attributes": [
- {
- "description": "int or tuple of 3 integers, factors by which to downscale\n (dim1, dim2, dim3). If only one integer is specified, the same\n window length will be used for all dimensions.",
- "name": "pool_size"
- },
- {
- "description": "int or tuple of 3 integers, or None. Strides values. If None,\n it will default to `pool_size`. If only one int is specified, the\n same stride size will be used for all dimensions.",
- "name": "strides"
- },
- {
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input such that output has the same\n height/width dimension as the input.",
- "name": "padding"
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape\n `(batch, spatial_dim1, spatial_dim2, spatial_dim3, channels)` while\n `\"channels_first\"` corresponds to inputs with shape\n `(batch, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.\n It defaults to the `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json`. If you never set it, then it\n will be `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 5D tensor with shape:\n `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`\n- If `data_format=\"channels_first\"`:\n 5D tensor with shape:\n `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n 5D tensor with shape:\n `(batch_size, pooled_dim1, pooled_dim2, pooled_dim3, channels)`\n- If `data_format=\"channels_first\"`:\n 5D tensor with shape:\n `(batch_size, channels, pooled_dim1, pooled_dim2, pooled_dim3)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "depth = 30\nheight = 30\nwidth = 30\nchannels = 3\n\ninputs = keras.layers.Input(shape=(depth, height, width, channels))\nlayer = keras.layers.MaxPooling3D(pool_size=3)\noutputs = layer(inputs) # Shape: (batch_size, 10, 10, 10, 3)"
- }
- ]
- },
- {
- "name": "MultiHeadAttention",
- "module": "keras.layers",
- "category": "Attention",
- "description": "MultiHeadAttention layer.\n\nThis is an implementation of multi-headed attention as described in the\npaper \"Attention is all you Need\"\n[Vaswani et al., 2017](https://arxiv.org/abs/1706.03762).\nIf `query`, `key,` `value` are the same, then\nthis is self-attention. Each timestep in `query` attends to the\ncorresponding sequence in `key`, and returns a fixed-width vector.\n\nThis layer first projects `query`, `key` and `value`. These are\n(effectively) a list of tensors of length `num_attention_heads`, where the\ncorresponding shapes are `(batch_size, <query dimensions>, key_dim)`,\n`(batch_size, <key/value dimensions>, key_dim)`,\n`(batch_size, <key/value dimensions>, value_dim)`.\n\nThen, the query and key tensors are dot-producted and scaled. These are\nsoftmaxed to obtain attention probabilities. The value tensors are then\ninterpolated by these probabilities, then concatenated back to a single\ntensor.\n\nFinally, the result tensor with the last dimension as `value_dim` can take\na linear projection and return.",
- "attributes": [
- {
- "description": "Number of attention heads.",
- "name": "num_heads"
- },
- {
- "description": "Size of each attention head for query and key.",
- "name": "key_dim"
- },
- {
- "description": "Size of each attention head for value.",
- "name": "value_dim"
- },
- {
- "description": "Dropout probability.",
- "name": "dropout"
- },
- {
- "description": "Boolean, whether the dense layers use bias vectors/matrices.",
- "name": "use_bias"
- },
- {
- "description": "The expected shape of an output tensor, besides the batch\n and sequence dims. If not specified, projects back to the query\n feature dim (the query input's last dimension).",
- "name": "output_shape"
- },
- {
- "description": "axes over which the attention is applied. `None` means\n attention over all axes, but batch, heads, and features.",
- "name": "attention_axes"
- },
- {
- "description": "Initializer for dense layer kernels.",
- "name": "kernel_initializer"
- },
- {
- "description": "Initializer for dense layer biases.",
- "name": "bias_initializer"
- },
- {
- "description": "Regularizer for dense layer kernels.",
- "name": "kernel_regularizer"
- },
- {
- "description": "Regularizer for dense layer biases.",
- "name": "bias_regularizer"
- },
- {
- "description": "Regularizer for dense layer activity.",
- "name": "activity_regularizer"
- },
- {
- "description": "Constraint for dense layer kernels.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint for dense layer kernels.",
- "name": "bias_constraint"
- },
- {
- "name": "seed",
- "description": "Optional integer to seed the dropout layer."
- },
- {
- "name": "flash_attention",
- "description": "If `None`, the layer attempts to use flash\n attention for faster and more memory-efficient attention\n computations when possible. This behavior can be configured using\n `keras.config.enable_flash_attention()` or\n `keras.config.disable_flash_attention()`."
- }
- ],
- "examples": [
- {
- "summary": "Performs 1D cross-attention over two sequence inputs with an attention mask.\nReturns the additional attention weights over heads.",
- "code": ">>> layer = MultiHeadAttention(num_heads=2, key_dim=2)\n>>> target = tf.keras.Input(shape=[8, 16])\n>>> source = tf.keras.Input(shape=[4, 16])\n>>> output_tensor, weights = layer(target, source,\n... return_attention_scores=True)\n>>> print(output_tensor.shape)\n(None, 8, 16)\n>>> print(weights.shape)\n(None, 2, 8, 4)"
- },
- {
- "summary": "Performs 2D self-attention over a 5D input tensor on axes 2 and 3.",
- "code": ">>> layer = MultiHeadAttention(\n... num_heads=2, key_dim=2, attention_axes=(2, 3))\n>>> input_tensor = tf.keras.Input(shape=[5, 3, 4, 16])\n>>> output_tensor = layer(input_tensor, input_tensor)\n>>> print(output_tensor.shape)\n(None, 5, 3, 4, 16)"
- }
- ]
- },
- {
- "name": "Multiply",
- "module": "keras.layers",
- "description": "Performs elementwise multiplication.\n\nIt takes as input a list of tensors, all of the same shape,\nand returns a single tensor (also of the same shape).",
- "inputs": [
- {
- "name": "inputs",
- "list": true
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 3, 4)\n>>> x1 = np.random.rand(*input_shape)\n>>> x2 = np.random.rand(*input_shape)\n>>> y = keras.layers.Multiply()([x1, x2])"
- },
- {
- "summary": "Usage in a Keras model:",
- "code": ">>> input1 = keras.layers.Input(shape=(16,))\n>>> x1 = keras.layers.Dense(8, activation='relu')(input1)\n>>> input2 = keras.layers.Input(shape=(32,))\n>>> x2 = keras.layers.Dense(8, activation='relu')(input2)\n>>> # equivalent to `y = keras.layers.multiply([x1, x2])`\n>>> y = keras.layers.Multiply()([x1, x2])\n>>> out = keras.layers.Dense(4)(y)\n>>> model = keras.models.Model(inputs=[input1, input2], outputs=out)"
- }
- ]
- },
- {
- "name": "Permute",
- "module": "keras.layers",
- "category": "Shape",
- "description": "Permutes the dimensions of the input according to a given pattern.\n\nUseful e.g. connecting RNNs and convnets.",
- "attributes": [
- {
- "description": "Tuple of integers. Permutation pattern does not include the\n batch dimension. Indexing starts at 1.\n For instance, `(1, 3, 2)` permutes the second and third dimensions\n of the input.",
- "name": "dims"
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same as the input shape, but with the dimensions re-ordered according\nto the specified pattern.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = keras.Input(shape=(10, 64))\n>>> y = keras.layers.Permute((2, 1))(x)\n>>> y.shape\n(None, 64, 10)"
- }
- ]
- },
- {
- "name": "PReLU",
- "module": "keras.layers",
- "category": "Activation",
- "description": "Parametric Rectified Linear Unit activation layer.\n\nFormula:\n``` python\nf(x) = alpha * x for x < 0\nf(x) = x for x >= 0\n```\nwhere `alpha` is a learned array with the same shape as x.",
- "attributes": [
- {
- "description": "Initializer function for the weights.",
- "name": "alpha_initializer"
- },
- {
- "description": "Regularizer for the weights.",
- "name": "alpha_regularizer",
- "visible": false
- },
- {
- "description": "Constraint for the weights.",
- "name": "alpha_constraint"
- },
- {
- "description": "The axes along which to share learnable parameters for the\n activation function. For example, if the incoming feature maps are\n from a 2D convolution with output shape\n `(batch, height, width, channels)`, and you wish to share parameters\n across space so that each filter only has one set of parameters,\n set `shared_axes=[1, 2]`.",
- "name": "shared_axes"
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments, such as `name` and `dtype`."
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the samples axis)\nwhen using this layer as the first layer in a model.",
- "name": "input"
- },
- {
- "name": "params"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as the input.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification](https://arxiv.org/abs/1502.01852)"
- }
- ]
- },
- {
- "name": "ReLU",
- "module": "keras.layers",
- "category": "Activation",
- "description": "Rectified Linear Unit activation function layer.\n\nFormula:\n``` python\nf(x) = max(x,0)\nf(x) = max_value if x >= max_value\nf(x) = x if threshold <= x < max_value\nf(x) = negative_slope * (x - threshold) otherwise\n```",
- "attributes": [
- {
- "description": "Float >= 0. Maximum activation value. None means unlimited.\n Defaults to `None`.",
- "name": "max_value"
- },
- {
- "description": "Float >= 0. Negative slope coefficient.\n Defaults to `0.0`.",
- "name": "negative_slope"
- },
- {
- "description": "Float >= 0. Threshold value for thresholded activation.\n Defaults to `0.0`.",
- "name": "threshold"
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments, such as `name` and `dtype`."
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the batch axis)\nwhen using this layer as the first layer in a model.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as the input.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "relu_layer = keras.layers.ReLU(\n max_value=10,\n negative_slope=0.5,\n threshold=0,\n)\ninput = np.array([-10, -5, 0.0, 5, 10])\nresult = relu_layer(input)\n# result = [-5. , -2.5, 0. , 5. , 10.]"
- }
- ]
- },
- {
- "name": "RepeatVector",
- "module": "keras.layers",
- "category": "Shape",
- "description": "Repeats the input n times.",
- "attributes": [
- {
- "description": "Integer, repetition factor.",
- "name": "n"
- }
- ],
- "inputs": [
- {
- "description": "2D tensor with shape `(batch_size, features)`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "3D tensor with shape `(batch_size, n, features)`.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = keras.Input(shape=(32,))\n>>> y = keras.layers.RepeatVector(3)(x)\n>>> y.shape\n(None, 3, 32)"
- }
- ]
- },
- {
- "name": "Reshape",
- "module": "keras.layers",
- "category": "Shape",
- "description": "Layer that reshapes inputs into the given shape.",
- "attributes": [
- {
- "description": "Target shape. Tuple of integers, does not include the\n samples dimension (batch size). One element of the `target_shape`\n can be -1 in which case the missing value is inferred from the\n size of the array and remaining dimensions.",
- "name": "target_shape"
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary, but required to be compatible with `target_shape`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "`(batch_size, *target_shape)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = keras.Input(shape=(12,))\n>>> y = keras.layers.Reshape((3, 4))(x)\n>>> y.shape\n(None, 3, 4)"
- },
- {
- "code": ">>> # another example with shape inference using `-1` as dimension\n>>> y = keras.layers.Reshape((-1, 2, 2))(x)\n>>> y.shape\n(None, 3, 2, 2)"
- }
- ]
- },
- {
- "name": "RNN",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Base class for recurrent layers.",
- "attributes": [
- {
- "default": false,
- "description": "Boolean (default `False`). Whether to return the last\n output in the output sequence, or the full sequence.",
- "name": "return_sequences"
- },
- {
- "default": false,
- "description": "Boolean (default `False`).\n Whether to return the last state in addition to the output.",
- "name": "return_state"
- },
- {
- "default": false,
- "description": "Boolean (default `False`).\n If `True`, process the input sequence backwards and return the\n reversed sequence.",
- "name": "go_backwards"
- },
- {
- "default": false,
- "description": "Boolean (default `False`). If True, the last state\n for each sample at index `i` in a batch will be used as initial\n state for the sample of index `i` in the following batch.",
- "name": "stateful"
- },
- {
- "default": false,
- "description": "Boolean (default `False`).\n If True, the network will be unrolled, else a symbolic loop will be\n used. Unrolling can speed-up a RNN, although it tends to be more\n memory-intensive. Unrolling is only suitable for short sequences.",
- "name": "unroll"
- },
- {
- "description": "A RNN cell instance or a list of RNN cell instances.\n A RNN cell is a class that has:\n - A `call(input_at_t, states_at_t)` method, returning\n `(output_at_t, states_at_t_plus_1)`. The call method of the\n cell can also take the optional argument `constants`, see\n section \"Note on passing external constants\" below.\n - A `state_size` attribute. This can be a single integer\n (single state) in which case it is the size of the recurrent\n state. This can also be a list/tuple of integers\n (one size per state).\n - A `output_size` attribute, a single integer.\n - A `get_initial_state(batch_size=None)`\n method that creates a tensor meant to be fed to `call()` as the\n initial state, if the user didn't specify any initial state\n via other means. The returned initial state should have\n shape `(batch_size, cell.state_size)`.\n The cell might choose to create a tensor full of zeros,\n or other values based on the cell's implementation.\n `inputs` is the input tensor to the RNN layer, with shape\n `(batch_size, timesteps, features)`.\n If this method is not implemented\n by the cell, the RNN layer will create a zero filled tensor\n with shape `(batch_size, cell.state_size)`.\n In the case that `cell` is a list of RNN cell instances, the cells\n will be stacked on top of each other in the RNN, resulting in an\n efficient stacked RNN.",
- "name": "cell"
- },
- {
- "description": "dimensionality of the input (integer).\n This argument (or alternatively,\n the keyword argument `input_shape`)\n is required when using this layer as the first layer in a model.",
- "name": "input_dim"
- },
- {
- "description": "Length of input sequences, to be specified\n when it is constant.\n This argument is required if you are going to connect\n `Flatten` then `Dense` layers upstream\n (without it, the shape of the dense outputs cannot be computed).\n Note that if the recurrent layer is not the first layer\n in your model, you would need to specify the input length\n at the level of the first layer\n (e.g. via the `input_shape` argument)\n",
- "name": "input_length"
- },
- {
- "description": "The shape format of the `inputs` and `outputs` tensors.\n If True, the inputs and outputs will be in shape\n `(timesteps, batch, ...)`, whereas in the False case, it will be\n `(batch, timesteps, ...)`. Using `time_major = True` is a bit more\n efficient because it avoids transposes at the beginning and end of the\n RNN calculation. However, most TensorFlow data is batch-major, so by\n default this function accepts input and emits output in batch-major\n form.",
- "name": "time_major"
- },
- {
- "description": "Boolean (default `False`).\n Whether the output should use zeros for the masked timesteps.\n Note that this field is only used when `return_sequences`\n is `True` and `mask` is provided.\n It can useful if you want to reuse the raw output sequence of\n the RNN without interference from the masked timesteps, e.g.,\n merging bidirectional RNNs.",
- "name": "zero_output_for_mask"
- }
- ],
- "inputs": [
- {
- "description": "3-D tensor with shape `(batch_size, timesteps, features)`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `return_state`: a list of tensors. The first tensor is\nthe output. The remaining tensors are the last states,\neach with shape `(batch_size, state_size)`, where `state_size` could\nbe a high dimension tensor shape.\n- If `return_sequences`: 3D tensor with shape\n`(batch_size, timesteps, output_size)`.\n\nMasking:\n\nThis layer supports masking for input data with a variable number\nof timesteps. To introduce masks to your data,\nuse a `keras.layers.Embedding` layer with the `mask_zero` parameter\nset to `True`.\n\nNote on using statefulness in RNNs:\n\nYou can set RNN layers to be 'stateful', which means that the states\ncomputed for the samples in one batch will be reused as initial states\nfor the samples in the next batch. This assumes a one-to-one mapping\nbetween samples in different successive batches.\n\nTo enable statefulness:\n\n- Specify `stateful=True` in the layer constructor.\n- Specify a fixed batch size for your model, by passing\n `batch_size=...` to the `Input` layer(s) of your model.\n Remember to also specify the same `batch_size=...` when\n calling `fit()`, or otherwise use a generator-like\n data source like a `keras.utils.PyDataset` or a\n `tf.data.Dataset`.\n- Specify `shuffle=False` when calling `fit()`, since your\n batches are expected to be temporally ordered.\n\nTo reset the states of your model, call `.reset_state()` on either\na specific layer, or on your entire model.\n\nNote on specifying the initial state of RNNs:\n\nYou can specify the initial state of RNN layers symbolically by\ncalling them with the keyword argument `initial_state`. The value of\n`initial_state` should be a tensor or list of tensors representing\nthe initial state of the RNN layer.\n\nYou can specify the initial state of RNN layers numerically by\ncalling `reset_state()` with the keyword argument `states`. The value of\n`states` should be a numpy array or list of numpy arrays representing\nthe initial state of the RNN layer.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "from keras.layers import RNN\nfrom keras import ops\n\n# First, let's define a RNN Cell, as a layer subclass.\nclass MinimalRNNCell(keras.Layer):\n\n def __init__(self, units, **kwargs):\n super().__init__(**kwargs)\n self.units = units\n self.state_size = units\n\n def build(self, input_shape):\n self.kernel = self.add_weight(shape=(input_shape[-1], self.units),\n initializer='uniform',\n name='kernel')\n self.recurrent_kernel = self.add_weight(\n shape=(self.units, self.units),\n initializer='uniform',\n name='recurrent_kernel')\n\n def call(self, inputs, states):\n prev_output = states[0]\n h = ops.matmul(inputs, self.kernel)\n output = h + ops.matmul(prev_output, self.recurrent_kernel)\n return output, [output]\n\n# Let's use this cell in a RNN layer:\n\ncell = MinimalRNNCell(32)\nx = keras.Input((None, 5))\nlayer = RNN(cell)\ny = layer(x)\n\n# Here's how to use the cell to build a stacked RNN:\n\ncells = [MinimalRNNCell(32), MinimalRNNCell(64)]\nx = keras.Input((None, 5))\nlayer = RNN(cells)\ny = layer(x)"
- }
- ]
- },
- {
- "name": "SeparableConv1D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "1D separable convolution layer.\n\nThis layer performs a depthwise convolution that acts separately on\nchannels, followed by a pointwise convolution that mixes channels.\nIf `use_bias` is True and a bias initializer is provided,\nit adds a bias vector to the output. It then optionally applies an\nactivation function to produce the final output.",
- "attributes": [
- {
- "description": "int, the dimensionality of the output space (i.e. the number\n of filters in the pointwise convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 1 integers, specifying the size of the\n depthwise convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "int or tuple/list of 1 integers, specifying the stride length\n of the depthwise convolution. If only one int is specified, the same\n stride size will be used for all dimensions. `strides > 1` is\n incompatible with `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input. When `padding=\"same\"` and\n `strides=1`, the output has the same size as the input.",
- "name": "padding"
- },
- {
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, steps, features)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, features, steps)`. It defaults to the `image_data_format`\n value found in your Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "description": "int or tuple/list of 1 integers, specifying the dilation\n rate to use for dilated convolution. If only one int is specified,\n the same dilation rate will be used for all dimensions.",
- "name": "dilation_rate"
- },
- {
- "description": "The number of depthwise convolution output channels\n for each input channel. The total number of depthwise convolution\n output channels will be equal to `input_channel * depth_multiplier`.",
- "name": "depth_multiplier"
- },
- {
- "description": "Activation function. If `None`, no activation is applied.",
- "name": "activation"
- },
- {
- "description": "bool, if `True`, bias will be added to the output.",
- "name": "use_bias"
- },
- {
- "description": "An initializer for the depthwise convolution\n kernel. If None, then the default initializer (`\"glorot_uniform\"`)\n will be used.",
- "name": "depthwise_initializer"
- },
- {
- "description": "An initializer for the pointwise convolution\n kernel. If None, then the default initializer (`\"glorot_uniform\"`)\n will be used.",
- "name": "pointwise_initializer"
- },
- {
- "description": "An initializer for the bias vector. If None, the\n default initializer ('\"zeros\"') will be used.",
- "name": "bias_initializer"
- },
- {
- "description": "Optional regularizer for the depthwise\n convolution kernel.",
- "name": "depthwise_regularizer"
- },
- {
- "description": "Optional regularizer for the pointwise\n convolution kernel.",
- "name": "pointwise_regularizer"
- },
- {
- "description": "Optional regularizer for the bias vector.",
- "name": "bias_regularizer"
- },
- {
- "description": "Optional regularizer function for the output.",
- "name": "activity_regularizer"
- },
- {
- "description": "Optional projection function to be applied to the\n depthwise kernel after being updated by an `Optimizer` (e.g. used\n for norm constraints or value constraints for layer weights). The\n function must take as input the unprojected variable and must return\n the projected variable (which must have the same shape).",
- "name": "depthwise_constraint"
- },
- {
- "description": "Optional projection function to be applied to the\n pointwise kernel after being updated by an `Optimizer`.",
- "name": "pointwise_constraint"
- },
- {
- "description": "Optional projection function to be applied to the\n bias after being updated by an `Optimizer`.",
- "name": "bias_constraint"
- },
- {
- "description": "Boolean, if `True` the weights of this layer will be marked as\n trainable (and listed in `layer.trainable_weights`).",
- "name": "trainable"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 3D tensor with shape: `(batch_shape, steps, channels)`\n- If `data_format=\"channels_first\"`:\n A 3D tensor with shape: `(batch_shape, channels, steps)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 3D tensor with shape: `(batch_shape, new_steps, filters)`\n- If `data_format=\"channels_first\"`:\n A 3D tensor with shape: `(batch_shape, filters, new_steps)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(4, 10, 12)\n>>> y = keras.layers.SeparableConv1D(3, 4, 3, 2, activation='relu')(x)\n>>> print(y.shape)\n(4, 4, 4)"
- }
- ]
- },
- {
- "name": "SeparableConv2D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "2D separable convolution layer.\n\nThis layer performs a depthwise convolution that acts separately on\nchannels, followed by a pointwise convolution that mixes channels.\nIf `use_bias` is True and a bias initializer is provided,\nit adds a bias vector to the output. It then optionally applies an\nactivation function to produce the final output.",
- "attributes": [
- {
- "default": "linear",
- "description": "Activation function. If `None`, no activation is applied.",
- "name": "activation"
- },
- {
- "default": "valid",
- "description": "string, either `\"valid\"` or `\"same\"` (case-insensitive).\n `\"valid\"` means no padding. `\"same\"` results in padding evenly to\n the left/right or up/down of the input. When `padding=\"same\"` and\n `strides=1`, the output has the same size as the input.",
- "name": "padding"
- },
- {
- "default": true,
- "description": "bool, if `True`, bias will be added to the output.",
- "name": "use_bias",
- "visible": false
- },
- {
- "default": "channels_last",
- "description": "string, either `\"channels_last\"` or `\"channels_first\"`.\n The ordering of the dimensions in the inputs. `\"channels_last\"`\n corresponds to inputs with shape `(batch, height, width, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch, channels, height, width)`. It defaults to the\n `image_data_format` value found in your Keras config file\n at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "default": [
- 1,
- 1
- ],
- "description": "int or tuple/list of 2 integers, specifying the stride length\n of the depthwise convolution. If only one int is specified, the same\n stride size will be used for all dimensions. `strides > 1` is\n incompatible with `dilation_rate > 1`.",
- "name": "strides"
- },
- {
- "default": [
- 1,
- 1
- ],
- "description": "int or tuple/list of 2 integers, specifying the dilation\n rate to use for dilated convolution. If only one int is specified,\n the same dilation rate will be used for all dimensions.",
- "name": "dilation_rate"
- },
- {
- "default": 1,
- "description": "The number of depthwise convolution output channels\n for each input channel. The total number of depthwise convolution\n output channels will be equal to `input_channel * depth_multiplier`.",
- "name": "depth_multiplier"
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "An initializer for the pointwise convolution\n kernel. If None, then the default initializer (`\"glorot_uniform\"`)\n will be used.",
- "name": "pointwise_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "An initializer for the depthwise convolution\n kernel. If None, then the default initializer (`\"glorot_uniform\"`)\n will be used.",
- "name": "depthwise_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "An initializer for the bias vector. If None, the\n default initializer ('\"zeros\"') will be used.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "int, the dimensionality of the output space (i.e. the number\n of filters in the pointwise convolution).",
- "name": "filters"
- },
- {
- "description": "int or tuple/list of 2 integers, specifying the size of the\n depthwise convolution window.",
- "name": "kernel_size"
- },
- {
- "description": "Optional regularizer for the depthwise\n convolution kernel.",
- "name": "depthwise_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the pointwise\n convolution kernel.",
- "name": "pointwise_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer for the bias vector.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Optional regularizer function for the output.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n depthwise kernel after being updated by an `Optimizer` (e.g. used\n for norm constraints or value constraints for layer weights). The\n function must take as input the unprojected variable and must return\n the projected variable (which must have the same shape).",
- "name": "depthwise_constraint",
- "visible": false
- },
- {
- "description": "Optional projection function to be applied to the\n pointwise kernel after being updated by an `Optimizer`.",
- "name": "pointwise_constraint"
- },
- {
- "description": "Optional projection function to be applied to the\n bias after being updated by an `Optimizer`.",
- "name": "bias_constraint"
- }
- ],
- "inputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, height, width, channels)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, channels, height, width)`",
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "description": "- If `data_format=\"channels_last\"`:\n A 4D tensor with shape: `(batch_size, new_height, new_width, filters)`\n- If `data_format=\"channels_first\"`:\n A 4D tensor with shape: `(batch_size, filters, new_height, new_width)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> x = np.random.rand(4, 10, 10, 12)\n>>> y = keras.layers.SeparableConv2D(3, 4, 3, 2, activation='relu')(x)\n>>> print(y.shape)\n(4, 4, 4, 4)"
- }
- ]
- },
- {
- "name": "Sigmoid",
- "category": "Activation"
- },
- {
- "name": "SimpleRNN",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Fully-connected RNN where the output is to be fed back as the new input.",
- "attributes": [
- {
- "default": false,
- "description": "Boolean. Whether to return the last output\n in the output sequence, or the full sequence. Default: `False`.",
- "name": "return_sequences"
- },
- {
- "default": false,
- "description": "Boolean. Whether to return the last state\n in addition to the output. Default: `False`.",
- "name": "return_state"
- },
- {
- "default": false,
- "description": "Boolean (default: `False`).\n If `True`, process the input sequence backwards and return the\n reversed sequence.",
- "name": "go_backwards"
- },
- {
- "default": false,
- "description": "Boolean (default: `False`). If `True`, the last state\n for each sample at index i in a batch will be used as the\n initial state for the sample of index i in the following batch.",
- "name": "stateful"
- },
- {
- "default": false,
- "description": "Boolean (default: `False`).\n If `True`, the network will be unrolled,\n else a symbolic loop will be used.\n Unrolling can speed-up an RNN,\n although it tends to be more memory-intensive.\n Unrolling is only suitable for short sequences.",
- "name": "unroll"
- },
- {
- "default": "tanh",
- "description": "Activation function to use.\n Default: hyperbolic tangent (`tanh`).\n If you pass None, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "default": true,
- "description": "Boolean, (default `True`), whether the layer uses\n a bias vector.",
- "name": "use_bias",
- "visible": false
- },
- {
- "default": {
- "class_name": "VarianceScaling",
- "config": {
- "distribution": "uniform",
- "mode": "fan_avg",
- "scale": 1,
- "seed": null
- }
- },
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs. Default:\n `\"glorot_uniform\"`.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Orthogonal",
- "config": {
- "gain": 1,
- "seed": null
- }
- },
- "description": "Initializer for the `recurrent_kernel`\n weights matrix, used for the linear transformation of the recurrent\n state. Default: `\"orthogonal\"`.",
- "name": "recurrent_initializer",
- "visible": false
- },
- {
- "default": {
- "class_name": "Zeros",
- "config": {}
- },
- "description": "Initializer for the bias vector. Default: `\"zeros\"`.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "default": 0,
- "description": "Float between 0 and 1.\n Fraction of the units to drop for the linear transformation\n of the inputs. Default: 0.",
- "name": "dropout"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1.\n Fraction of the units to drop for the linear transformation of the\n recurrent state. Default: 0.",
- "name": "recurrent_dropout"
- },
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.\n Default: `None`.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the output of the\n layer (its \"activation\"). Default: `None`.",
- "name": "activity_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.\n Default: `None`.",
- "name": "bias_constraint"
- },
- {
- "description": "`None`.",
- "name": "Default"
- }
- ],
- "inputs": [
- {
- "name": "input"
- },
- {
- "name": "kernel"
- },
- {
- "name": "recurrent_kernel"
- },
- {
- "name": "bias"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": "inputs = np.random.random((32, 10, 8))\nsimple_rnn = keras.layers.SimpleRNN(4)\noutput = simple_rnn(inputs) # The output has shape `(32, 4)`.\nsimple_rnn = keras.layers.SimpleRNN(\n 4, return_sequences=True, return_state=True\n)\n# whole_sequence_output has shape `(32, 10, 4)`.\n# final_state has shape `(32, 4)`.\nwhole_sequence_output, final_state = simple_rnn(inputs)"
- }
- ]
- },
- {
- "name": "SimpleRNNCell",
- "module": "keras.layers",
- "description": "Cell class for SimpleRNN.\n\nThis class processes one step within the whole time sequence input, whereas\n`keras.layer.SimpleRNN` processes the whole sequence.",
- "attributes": [
- {
- "description": "Positive integer, dimensionality of the output space.",
- "name": "units"
- },
- {
- "description": "Activation function to use.\n Default: hyperbolic tangent (`tanh`).\n If you pass `None`, no activation is applied\n (ie. \"linear\" activation: `a(x) = x`).",
- "name": "activation"
- },
- {
- "description": "Boolean, (default `True`), whether the layer\n should use a bias vector.",
- "name": "use_bias",
- "visible": false
- },
- {
- "description": "Initializer for the `kernel` weights matrix,\n used for the linear transformation of the inputs. Default:\n `\"glorot_uniform\"`.",
- "name": "kernel_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the `recurrent_kernel`\n weights matrix, used for the linear transformation\n of the recurrent state. Default: `\"orthogonal\"`.",
- "name": "recurrent_initializer",
- "visible": false
- },
- {
- "description": "Initializer for the bias vector. Default: `\"zeros\"`.",
- "name": "bias_initializer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_regularizer",
- "visible": false
- },
- {
- "description": "Regularizer function applied to the bias vector.\n Default: `None`.",
- "name": "bias_regularizer",
- "visible": false
- },
- {
- "description": "Constraint function applied to the `kernel` weights\n matrix. Default: `None`.",
- "name": "kernel_constraint"
- },
- {
- "description": "Constraint function applied to the\n `recurrent_kernel` weights matrix. Default: `None`.",
- "name": "recurrent_constraint"
- },
- {
- "description": "Constraint function applied to the bias vector.\n Default: `None`.",
- "name": "bias_constraint"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop for the\n linear transformation of the inputs. Default: 0.",
- "name": "dropout"
- },
- {
- "default": 0,
- "description": "Float between 0 and 1. Fraction of the units to drop\n for the linear transformation of the recurrent state. Default: 0.",
- "name": "recurrent_dropout"
- },
- {
- "description": "`None`.",
- "name": "Default"
- },
- {
- "name": "seed",
- "description": "Random seed for dropout."
- }
- ],
- "examples": [
- {
- "code": "inputs = np.random.random([32, 10, 8]).astype(np.float32)\nrnn = keras.layers.RNN(keras.layers.SimpleRNNCell(4))\noutput = rnn(inputs) # The output has shape `(32, 4)`.\nrnn = keras.layers.RNN(\n keras.layers.SimpleRNNCell(4),\n return_sequences=True,\n return_state=True\n)\n# whole_sequence_output has shape `(32, 10, 4)`.\n# final_state has shape `(32, 4)`.\nwhole_sequence_output, final_state = rnn(inputs)"
- }
- ]
- },
- {
- "name": "Softmax",
- "module": "keras.layers",
- "category": "Activation",
- "description": "Softmax activation layer.\n\nFormula:\n``` python\nexp_x = exp(x - max(x))\nf(x) = exp_x / sum(exp_x)\n```",
- "inputs": [
- {
- "name": "input",
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the samples axis)\nwhen using this layer as the first layer in a model."
- }
- ],
- "outputs": [
- {
- "name": "output",
- "description": "Same shape as the input."
- }
- ],
- "attributes": [
- {
- "name": "axis",
- "description": "Integer, or list of Integers, axis along which the softmax\n normalization is applied."
- },
- {
- "name": "**kwargs",
- "description": "Base layer keyword arguments, such as `name` and `dtype`."
- }
- ],
- "examples": [
- {
- "code": ">>> softmax_layer = keras.layers.Softmax()\n>>> input = np.array([1.0, 2.0, 1.0])\n>>> result = softmax_layer(input)\n>>> result\n[0.21194157, 0.5761169, 0.21194157]"
- }
- ]
- },
- {
- "name": "SoftPlus",
- "category": "Activation"
- },
- {
- "name": "SoftSign",
- "category": "Activation"
- },
- {
- "name": "SpatialDropout1D",
- "module": "keras.layers",
- "category": "Dropout",
- "description": "Spatial 1D version of Dropout.\n\nThis layer performs the same function as Dropout, however, it drops\nentire 1D feature maps instead of individual elements. If adjacent frames\nwithin feature maps are strongly correlated (as is normally the case in\nearly convolution layers) then regular dropout will not regularize the\nactivations and will otherwise just result in an effective learning rate\ndecrease. In this case, `SpatialDropout1D` will help promote independence\nbetween feature maps and should be used instead.",
- "attributes": [
- {
- "description": "Float between 0 and 1. Fraction of the input units to drop.",
- "name": "rate"
- }
- ],
- "inputs": [
- {
- "description": "3D tensor with shape: `(samples, timesteps, channels)`\n\nOutput shape: Same as input.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same as input.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Tompson et al., 2014](https://arxiv.org/abs/1411.4280)"
- }
- ]
- },
- {
- "name": "SpatialDropout2D",
- "module": "keras.layers",
- "category": "Dropout",
- "description": "Spatial 2D version of Dropout.\n\nThis version performs the same function as Dropout, however, it drops\nentire 2D feature maps instead of individual elements. If adjacent pixels\nwithin feature maps are strongly correlated (as is normally the case in\nearly convolution layers) then regular dropout will not regularize the\nactivations and will otherwise just result in an effective learning rate\ndecrease. In this case, `SpatialDropout2D` will help promote independence\nbetween feature maps and should be used instead.",
- "attributes": [
- {
- "description": "Float between 0 and 1. Fraction of the input units to drop.",
- "name": "rate"
- },
- {
- "description": "`\"channels_first\"` or `\"channels_last\"`.\n In `\"channels_first\"` mode, the channels dimension (the depth)\n is at index 1, in `\"channels_last\"` mode is it at index 3.\n It defaults to the `image_data_format` value found in your\n Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "4D tensor with shape: `(samples, channels, rows, cols)` if\n data_format='channels_first'\n or 4D tensor with shape: `(samples, rows, cols, channels)` if\n data_format='channels_last'.\n\nOutput shape: Same as input.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same as input.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Tompson et al., 2014](https://arxiv.org/abs/1411.4280)"
- }
- ]
- },
- {
- "name": "SpatialDropout3D",
- "module": "keras.layers",
- "category": "Dropout",
- "description": "Spatial 3D version of Dropout.\n\nThis version performs the same function as Dropout, however, it drops\nentire 3D feature maps instead of individual elements. If adjacent voxels\nwithin feature maps are strongly correlated (as is normally the case in\nearly convolution layers) then regular dropout will not regularize the\nactivations and will otherwise just result in an effective learning rate\ndecrease. In this case, SpatialDropout3D will help promote independence\nbetween feature maps and should be used instead.",
- "attributes": [
- {
- "description": "Float between 0 and 1. Fraction of the input units to drop.",
- "name": "rate"
- },
- {
- "description": "`\"channels_first\"` or `\"channels_last\"`.\n In `\"channels_first\"` mode, the channels dimension (the depth)\n is at index 1, in `\"channels_last\"` mode is it at index 4.\n It defaults to the `image_data_format` value found in your\n Keras config file at `~/.keras/keras.json`.\n If you never set it, then it will be `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "5D tensor with shape: `(samples, channels, dim1, dim2, dim3)` if\n data_format='channels_first'\n or 5D tensor with shape: `(samples, dim1, dim2, dim3, channels)` if\n data_format='channels_last'.\n\nOutput shape: Same as input.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same as input.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Tompson et al., 2014](https://arxiv.org/abs/1411.4280)"
- }
- ]
- },
- {
- "name": "StackedRNNCells",
- "module": "keras.layers",
- "description": "Wrapper allowing a stack of RNN cells to behave as a single cell.\n\nUsed to implement efficient stacked RNNs.",
- "attributes": [
- {
- "description": "List of RNN cell instances.",
- "name": "cells"
- }
- ],
- "examples": [
- {
- "code": "batch_size = 3\nsentence_length = 5\nnum_features = 2\nnew_shape = (batch_size, sentence_length, num_features)\nx = np.reshape(np.arange(30), new_shape)\n\nrnn_cells = [keras.layers.LSTMCell(128) for _ in range(2)]\nstacked_lstm = keras.layers.StackedRNNCells(rnn_cells)\nlstm_layer = keras.layers.RNN(stacked_lstm)\n\nresult = lstm_layer(x)"
- }
- ]
- },
- {
- "name": "Subtract",
- "module": "keras.layers",
- "description": "Performs elementwise subtraction.\n\nIt takes as input a list of tensors of size 2 both of the\nsame shape, and returns a single tensor (inputs[0] - inputs[1])\nof same shape.",
- "inputs": [
- {
- "name": "x"
- },
- {
- "name": "y"
- }
- ],
- "outputs": [
- {
- "name": "z"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 3, 4)\n>>> x1 = np.random.rand(*input_shape)\n>>> x2 = np.random.rand(*input_shape)\n>>> y = keras.layers.Subtract()([x1, x2])"
- },
- {
- "summary": "Usage in a Keras model:",
- "code": ">>> input1 = keras.layers.Input(shape=(16,))\n>>> x1 = keras.layers.Dense(8, activation='relu')(input1)\n>>> input2 = keras.layers.Input(shape=(32,))\n>>> x2 = keras.layers.Dense(8, activation='relu')(input2)\n>>> # equivalent to `subtracted = keras.layers.subtract([x1, x2])`\n>>> subtracted = keras.layers.Subtract()([x1, x2])\n>>> out = keras.layers.Dense(4)(subtracted)\n>>> model = keras.models.Model(inputs=[input1, input2], outputs=out)"
- }
- ]
- },
- {
- "name": "TanH",
- "category": "Activation"
- },
- {
- "name": "ThresholdedReLU",
- "module": "keras.layers",
- "category": "Activation",
- "description": "Thresholded Rectified Linear Unit.\n\nIt follows:\n\n```\n f(x) = x for x > theta\n f(x) = 0 otherwise`\n```",
- "attributes": [
- {
- "description": "Float >= 0. Threshold location of activation.",
- "name": "theta"
- }
- ],
- "inputs": [
- {
- "description": "Arbitrary. Use the keyword argument `input_shape`\n(tuple of integers, does not include the samples axis)\nwhen using this layer as the first layer in a model.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "Same shape as the input.",
- "name": "output"
- }
- ],
- "references": [
- {
- "description": "[Zero-Bias Autoencoders and the Benefits of Co-Adapting Features]( https://arxiv.org/abs/1402.3337)"
- }
- ]
- },
- {
- "name": "TimeDistributed",
- "module": "keras.layers",
- "description": "This wrapper allows to apply a layer to every temporal slice of an input.\n\nEvery input should be at least 3D, and the dimension of index one of the\nfirst input will be considered to be the temporal dimension.\n\nConsider a batch of 32 video samples, where each sample is a 128x128 RGB\nimage with `channels_last` data format, across 10 timesteps.\nThe batch input shape is `(32, 10, 128, 128, 3)`.\n\nYou can then use `TimeDistributed` to apply the same `Conv2D` layer to each\nof the 10 timesteps, independently:\n\n```\n>>> inputs = layers.Input(shape=(10, 128, 128, 3), batch_size=32)\n>>> conv_2d_layer = layers.Conv2D(64, (3, 3))\n>>> outputs = layers.TimeDistributed(conv_2d_layer)(inputs)\n>>> outputs.shape\n(32, 10, 126, 126, 64)\n```\n\nBecause `TimeDistributed` applies the same instance of `Conv2D` to each of\nthe timestamps, the same set of weights are used at each timestamp.",
- "attributes": [
- {
- "description": "a `keras.layers.Layer` instance.",
- "name": "layer"
- }
- ],
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "UpSampling1D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Upsampling layer for 1D inputs.\n\nRepeats each temporal step `size` times along the time axis.",
- "attributes": [
- {
- "default": "channels_last",
- "name": "data_format"
- },
- {
- "description": "Integer. Upsampling factor.",
- "name": "size"
- }
- ],
- "inputs": [
- {
- "description": "3D tensor with shape: `(batch_size, steps, features)`.",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "3D tensor with shape: `(batch_size, upsampled_steps, features)`.",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 2, 3)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> x\n[[[ 0 1 2]\n [ 3 4 5]]\n [[ 6 7 8]\n [ 9 10 11]]]\n>>> y = keras.layers.UpSampling1D(size=2)(x)\n>>> y\n[[[ 0. 1. 2.]\n [ 0. 1. 2.]\n [ 3. 4. 5.]\n [ 3. 4. 5.]]\n [[ 6. 7. 8.]\n [ 6. 7. 8.]\n [ 9. 10. 11.]\n [ 9. 10. 11.]]]"
- }
- ]
- },
- {
- "name": "UpSampling2D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Upsampling layer for 2D inputs.\n\nThe implementation uses interpolative resizing, given the resize method\n(specified by the `interpolation` argument). Use `interpolation=nearest`\nto repeat the rows and columns of the data.",
- "attributes": [
- {
- "default": "channels_last",
- "description": "A string,\n one of `\"channels_last\"` (default) or `\"channels_first\"`.\n The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch_size, height, width, channels)` while `\"channels_first\"`\n corresponds to inputs with shape\n `(batch_size, channels, height, width)`.\n When unspecified, uses\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json` (if exists) else `\"channels_last\"`.\n Defaults to `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "description": "Int, or tuple of 2 integers.\n The upsampling factors for rows and columns.",
- "name": "size"
- },
- {
- "description": "A string, one of `\"bicubic\"`, `\"bilinear\"`, `\"lanczos3\"`,\n `\"lanczos5\"`, `\"nearest\"`.",
- "name": "interpolation"
- }
- ],
- "inputs": [
- {
- "description": "4D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, rows, cols, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, rows, cols)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "4D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, upsampled_rows, upsampled_cols, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, upsampled_rows, upsampled_cols)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 2, 1, 3)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> print(x)\n[[[[ 0 1 2]]\n [[ 3 4 5]]]\n [[[ 6 7 8]]\n [[ 9 10 11]]]]\n>>> y = keras.layers.UpSampling2D(size=(1, 2))(x)\n>>> print(y)\n[[[[ 0 1 2]\n [ 0 1 2]]\n [[ 3 4 5]\n [ 3 4 5]]]\n [[[ 6 7 8]\n [ 6 7 8]]\n [[ 9 10 11]\n [ 9 10 11]]]]"
- }
- ]
- },
- {
- "name": "UpSampling3D",
- "module": "keras.layers",
- "category": "Layer",
- "description": "Upsampling layer for 3D inputs.\n\nRepeats the 1st, 2nd and 3rd dimensions\nof the data by `size[0]`, `size[1]` and `size[2]` respectively.",
- "attributes": [
- {
- "default": "channels_last",
- "description": "A string,\n one of `\"channels_last\"` (default) or `\"channels_first\"`.\n The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.\n When unspecified, uses\n `image_data_format` value found in your Keras config file at\n `~/.keras/keras.json` (if exists) else `\"channels_last\"`.\n Defaults to `\"channels_last\"`.",
- "name": "data_format"
- },
- {
- "description": "Int, or tuple of 3 integers.\n The upsampling factors for dim1, dim2 and dim3.",
- "name": "size"
- }
- ],
- "inputs": [
- {
- "description": "5D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, dim1, dim2, dim3, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, dim1, dim2, dim3)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "5D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, upsampled_dim1, upsampled_dim2, upsampled_dim3,\n channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, upsampled_dim1, upsampled_dim2,\n upsampled_dim3)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 1, 2, 1, 3)\n>>> x = np.ones(input_shape)\n>>> y = keras.layers.UpSampling3D(size=(2, 2, 2))(x)\n>>> y.shape\n(2, 2, 4, 2, 3)"
- }
- ]
- },
- {
- "name": "ZeroPadding1D",
- "module": "keras.layers",
- "category": "Tensor",
- "description": "Zero-padding layer for 1D input (e.g. temporal sequence).",
- "attributes": [
- {
- "description": "Int, or tuple of int (length 2), or dictionary.\n - If int: how many zeros to add at the beginning and end of\n the padding dimension (axis 1).\n - If tuple of 2 ints: how many zeros to add at the beginning and the\n end of the padding dimension (`(left_pad, right_pad)`).",
- "name": "padding"
- },
- {
- "name": "data_format",
- "description": "A string, one of `\"channels_last\"` (default) or\n `\"channels_first\"`. The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch_size, axis_to_pad, channels)` while `\"channels_first\"`\n corresponds to inputs with shape\n `(batch_size, channels, axis_to_pad)`.\n When unspecified, uses `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json` (if exists). Defaults to\n `\"channels_last\"`."
- }
- ],
- "inputs": [
- {
- "description": "3D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, axis_to_pad, features)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, features, axis_to_pad)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "3D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, padded_axis, features)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, features, padded_axis)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (2, 2, 3)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> x\n[[[ 0 1 2]\n [ 3 4 5]]\n [[ 6 7 8]\n [ 9 10 11]]]\n>>> y = keras.layers.ZeroPadding1D(padding=2)(x)\n>>> y\n[[[ 0 0 0]\n [ 0 0 0]\n [ 0 1 2]\n [ 3 4 5]\n [ 0 0 0]\n [ 0 0 0]]\n [[ 0 0 0]\n [ 0 0 0]\n [ 6 7 8]\n [ 9 10 11]\n [ 0 0 0]\n [ 0 0 0]]]"
- }
- ]
- },
- {
- "name": "ZeroPadding2D",
- "module": "keras.layers",
- "category": "Tensor",
- "description": "Zero-padding layer for 2D input (e.g. picture).\n\nThis layer can add rows and columns of zeros at the top, bottom, left and\nright side of an image tensor.",
- "attributes": [
- {
- "description": "Int, or tuple of 2 ints, or tuple of 2 tuples of 2 ints.\n - If int: the same symmetric padding is applied to height and width.\n - If tuple of 2 ints: interpreted as two different symmetric padding\n values for height and width:\n `(symmetric_height_pad, symmetric_width_pad)`.\n - If tuple of 2 tuples of 2 ints: interpreted as\n `((top_pad, bottom_pad), (left_pad, right_pad))`.",
- "name": "padding"
- },
- {
- "description": "A string, one of `\"channels_last\"` (default) or\n `\"channels_first\"`. The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch_size, height, width, channels)` while `\"channels_first\"`\n corresponds to inputs with shape\n `(batch_size, channels, height, width)`.\n When unspecified, uses `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json` (if exists). Defaults to\n `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "4D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, height, width, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, height, width)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "4D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, padded_height, padded_width, channels)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, channels, padded_height, padded_width)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (1, 1, 2, 2)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> x\n[[[[0 1]\n [2 3]]]]\n>>> y = keras.layers.ZeroPadding2D(padding=1)(x)\n>>> y\n[[[[0 0]\n [0 0]\n [0 0]\n [0 0]]\n [[0 0]\n [0 1]\n [2 3]\n [0 0]]\n [[0 0]\n [0 0]\n [0 0]\n [0 0]]]]"
- }
- ]
- },
- {
- "name": "ZeroPadding3D",
- "module": "keras.layers",
- "category": "Tensor",
- "description": "Zero-padding layer for 3D data (spatial or spatio-temporal).",
- "attributes": [
- {
- "description": "Int, or tuple of 3 ints, or tuple of 3 tuples of 2 ints.\n - If int: the same symmetric padding is applied to depth, height,\n and width.\n - If tuple of 3 ints: interpreted as three different symmetric\n padding values for depth, height, and width:\n `(symmetric_dim1_pad, symmetric_dim2_pad, symmetric_dim3_pad)`.\n - If tuple of 3 tuples of 2 ints: interpreted as\n `((left_dim1_pad, right_dim1_pad), (left_dim2_pad,\n right_dim2_pad), (left_dim3_pad, right_dim3_pad))`.",
- "name": "padding"
- },
- {
- "description": "A string, one of `\"channels_last\"` (default) or\n `\"channels_first\"`. The ordering of the dimensions in the inputs.\n `\"channels_last\"` corresponds to inputs with shape\n `(batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels)`\n while `\"channels_first\"` corresponds to inputs with shape\n `(batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.\n When unspecified, uses `image_data_format` value found in your Keras\n config file at `~/.keras/keras.json` (if exists). Defaults to\n `\"channels_last\"`.",
- "name": "data_format"
- }
- ],
- "inputs": [
- {
- "description": "5D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, first_axis_to_pad, second_axis_to_pad,\n third_axis_to_pad, depth)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, depth, first_axis_to_pad, second_axis_to_pad,\n third_axis_to_pad)`",
- "name": "input"
- }
- ],
- "outputs": [
- {
- "description": "5D tensor with shape:\n- If `data_format` is `\"channels_last\"`:\n `(batch_size, first_padded_axis, second_padded_axis,\n third_axis_to_pad, depth)`\n- If `data_format` is `\"channels_first\"`:\n `(batch_size, depth, first_padded_axis, second_padded_axis,\n third_axis_to_pad)`",
- "name": "output"
- }
- ],
- "examples": [
- {
- "code": ">>> input_shape = (1, 1, 2, 2, 3)\n>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)\n>>> y = keras.layers.ZeroPadding3D(padding=2)(x)\n>>> y.shape\n(1, 5, 6, 6, 3)"
- }
- ]
- },
- {
- "name": "nn.relu",
- "category": "Activation",
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "math.add",
- "inputs": [
- {
- "name": "x",
- "type": "Tensor"
- },
- {
- "name": "y",
- "type": "Tensor"
- }
- ],
- "outputs": [
- {
- "name": "z"
- }
- ]
- },
- {
- "name": "__operators__.add",
- "inputs": [
- {
- "name": "x",
- "type": "Tensor"
- },
- {
- "name": "y",
- "type": "Tensor"
- }
- ],
- "outputs": [
- {
- "name": "z"
- }
- ]
- },
- {
- "name": "linalg.matmul",
- "attributes": [
- {
- "name": "transpose_a",
- "type": "boolean"
- },
- {
- "name": "transpose_b",
- "type": "boolean"
- }
- ],
- "inputs": [
- {
- "name": "a",
- "type": "Tensor"
- },
- {
- "name": "b",
- "type": "Tensor"
- }
- ],
- "outputs": [
- {
- "name": "c",
- "type": "Tensor"
- }
- ]
- },
- {
- "name": "nn.abs",
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "math.sigmoid",
- "category": "Activation",
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "reshape",
- "category": "Shape",
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "concat",
- "category": "Tensor",
- "inputs": [
- {
- "name": "inputs",
- "list": true
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- },
- {
- "name": "compat.v1.transpose",
- "category": "Shape",
- "inputs": [
- {
- "name": "input"
- }
- ],
- "outputs": [
- {
- "name": "output"
- }
- ]
- }
- ]
|