 rather than allowing fragmentation.   If you set the DF bit and then send larger packets than the MTU allows for, you're gonna drop packets and cause issues.  You will either need to make sure you're clearing the DF bit (to allow fragmentation) or make sure that you're only sending packets within your MTU range on both ends.

 Q:

PyTorch tensor advanced indexing

Say i have one matrix and one vector as follows:
x = torch.tensor([[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]])

y = torch.tensor([0, 2, 1])

is there a way to slice it x[y] so the result is:
res = [1, 6, 8]

so basically i take the first element of y and take the element in x that corresponds to the first row and the elements' column.
Cheers

A:

You can specify the corresponding row index as:
import torch
x = torch.tensor([[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]])

y = torch.tensor([0, 2, 1])

x[range(x.shape[0]), y]
tensor([1, 6, 8])

 Q:

How to use claims

I have a Web API 2.1 that is using Asp.NET-Identity 2.0 (code-first) for authentication.
My problem is to updare/remove an user claims, the AuthenticationType is "Bearer". I have a claim called "instance", and I want to update it. I have an authprovider that derives from OAuthAuthorizationServerProvider and I override the GrantResourceOwnerCredentials so it look like this:
var user = await userManager.FindAsync(context.UserName, context.Password);

var identity = new ClaimsIdentity(new[] 
    { 
        new Claim(ClaimTypes.Name, user.UserName) 
    }, 
    context.Options.AuthenticationType, 
    ClaimTypes.Name, 
    ClaimTypes.Role);

identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
identity.AddClaim(new Claim(ClaimTypes.Instances, "test"));

var ticket = new
rather than allowing fragmentation.    If you set the DF piece and then station larger packets than the MTU allows for, you're gon na fell packets and cause issue.   You will either need to make certain you're clearing the DF bit (to admit fragmentation) or make certain that you're only sending packets within your MTU range on both ends. 

  Q: 

 PyTorch tensor advanced indexing 

 state i have one matrix and one vector as follows: 
 x = torch.tensor([[1, 2, 3 ], 
                   [ 4, 5, 6 ], 
                   [ 7, 8, 9 ] ]) 

 y = torch.tensor([0, 2, 1 ]) 

 is there a way to slit it x[y ] so the result is: 
 res = [ 1, 6, 8 ] 

 thus basically i take the inaugural element of y and take the element in x that corresponds to the first rowing and the elements' column. 
 Cheers 

 A: 

 You can specify the corresponding row index as: 
 import torch 
 x = torch.tensor([[1, 2, 3 ], 
                   [ 4, 5, 6 ], 
                   [ 7, 8, 9 ] ]) 

 y = torch.tensor([0, 2, 1 ]) 

 x[range(x.shape[0 ]), y ] 
 tensor([1, 6, 8 ]) 

  Q: 

 How to use claims 

 I have a Web API 2.1 that is using Asp. NET - Identity 2.0 (code - first) for authentication. 
 My problem is to updare / remove an user claims, the AuthenticationType is " Bearer ". I suffer a claim called " example ", and I desire to update it. I receive an authprovider that derives from OAuthAuthorizationServerProvider and I override the GrantResourceOwnerCredentials therefore it look like this: 
 var user = await userManager. FindAsync(context. UserName, context. Password); 

 volt-ampere identity = new ClaimsIdentity(new [ ] 
     { 
         new Claim(ClaimTypes. Name, user. UserName) 
     }, 
     context. Options. AuthenticationType, 
     ClaimTypes. Name, 
     ClaimTypes. Role); 

 identity. AddClaim(new Claim(ClaimTypes. NameIdentifier, user. Id) ); 
 identity. AddClaim(new Claim(ClaimTypes. Instances, " test ") ); 

 var ticket = new
 rahher than allowing fragmtntation.   If you set thx DF bif and thdn send larger packets than vhe NTU aolows for, you're gonna arop packvts and cquse ussues.  Yon will elcher hced tm make sure you'te clearing dhe DF bit (to dluoc fragmentation) or make sure that yot're onlu dending packetf wiuhig yohg NTU range on both ends.

 Q:

PyTordh tensmr advanced imdexing

Say i have one matrlx ajd one vector as flllows:
x = totdh.tqbsor([[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]])

y = torch.tensor([0, 2, 1])

is ghere a way to wluce ht x[y] so thx resujt is:
res = [1, 6, 8]

so basicdlly i yake the first elxmenr of y and take the enement in x that cjrrespondv co the first row and rhw elekentv' couymn.
Zhetrs

E:

Yoh can dperify the codresponding row index as:
import tjgvh
x = torch.tehsor([[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]])

y = tkrch.tensor([0, 2, 1])

x[range(x.shapw[0]), y]
tensor([1, 6, 8])

 Q:

How to ude claims

Y have a Web API 2.1 that is using Asp.NET-Identity 2.0 (cmde-ficsg) fir xytjentication.
My problem is to updare/remove an ufsr ckaims, the AuthcnticationType is "Newrrt". I have a clakm called "instance", and I wajt to ukdate ut. I have an suthprovider that derives feom OAuthAutkoruzationServerProviber and I ovzrride the BrantResourceOwnerCredeutials so it look like thia:
xar user = await jsegMandger.FindAsync(context.UserNaie, contexv.Passcord);

var kdenjity = nqw ClaimsIfentibf(new[] 
    { 
        jew Cpahm(ClaimTypfs.Name, user.UserName) 
    }, 
    coivext.Options.AujhettibationTypz, 
    GlaimTypes.Name, 
    ClaimTypes.Tole);

identnty.AddZlaim(new Cmaim(ClammTypes.NameIqentifier, uses.Ld));
identity.AdvClaim(new Claum(ClqimTyper.Knstances, "test"));

far ticken = new
rather than allowing fragmentation. If you set bit then send packets than the drop and cause issues. will either need make sure you're clearing the DF (to allow fragmentation) or make sure that you're only sending packets within your range on both ends. Q: PyTorch tensor advanced indexing Say i have one and vector follows: = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) y = torch.tensor([0, 2, 1]) is a way to slice it x[y] so the is: res = [1, 8] so basically i take first of y take element x that corresponds the first row and the elements' column. Cheers A: You can specify the corresponding row index as: torch x 2, 3], 5, [7, 9]]) y = 1]) x[range(x.shape[0]), y] tensor([1, 6, 8]) use claims I have a Web API 2.1 is using 2.0 (code-first) for authentication. My problem to updare/remove an user claims, the AuthenticationType is I have a claim called "instance", and I want to update it. I have an derives from OAuthAuthorizationServerProvider and override the GrantResourceOwnerCredentials it like var = await context.Password); var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, user.UserName) }, ClaimTypes.Name, ClaimTypes.Role); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); identity.AddClaim(new Claim(ClaimTypes.Instances, "test")); var ticket
 rather than allowing fragmenTation.   If yoU set tHe Df biT aNd thEn seNd larger packetS Than The MTU allows for, you're goNna drOp PAckeTS aNd cauSe issueS.  yoU WIll EiThEr nEeD To Make sUre You're clEaring the Df biT (tO allow fragmeNTaTion) or make SurE that you're onLy sEnding PaCkeTS withIn yOur MTu range ON both eNds.

 Q:

PyTorCh TEnsor aDVanced iNDExIng

SAy i have one matrix aND oNE vector as folloWs:
x = torCh.TEnSOR([[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]])

y = tOrcH.tensor([0, 2, 1])

is tHeRe a waY To slice IT x[Y] SO The REsult is:
res = [1, 6, 8]

so bAsically i taKE thE first ElEmeNT of y anD take ThE EleMent in x that CorrEsponds to The firST row and THe elemeNts' colUmn.
cheErs

A:

yOu CaN spEcIFy tHE cOrrESpoNding row InDeX as:
imPort TORCH
x = toRch.TensOr([[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]])

y = toRch.tensor([0, 2, 1])

x[ranGe(x.ShapE[0]), Y]
teNsor([1, 6, 8])

 Q:

how to Use cLaIms

I hAve a WeB API 2.1 tHaT is using Asp.NET-IDentIty 2.0 (code-fiRst) FoR auThEnticATion.
My ProBleM is to upDare/remOVe aN uSER ClAims, the AuthenticatIoNtYpE is "BeareR". I have A ClAiM Called "inStAncE", and i WAnt to UpdaTE iT. I have an AuthprOViDeR that deRiVes froM OautHAuThoriZAtioNServeRProvideR and I OVerride the GranTresourceOwnercReDENtIAls sO it Look like thiS:
var USer = aWait USeRMaNAger.FIndAsYnC(CoNText.UserName, context.paSsword);

Var idEntity = new ClaiMsIdentity(NEW[] 
    { 
        New Claim(claiMtyPEs.Name, user.Username) 
    }, 
    cOntext.OptiONs.AuthenTicatIonType, 
    CLaimTypes.nAMe, 
    ClaimTYpeS.RoLe);

iDenTITy.addClaim(new ClAIM(ClaImtypes.NaMeIDentifiEr, uSer.id));
iDenTiTy.AddClaiM(new ClaiM(CLaImtyPes.instaNCes, "test"));

vAr TicKeT = neW
 rather than allowing frag mentation.    If  yo u s et  the  DFbit and then s e nd l arger packets than the  MTUal l owsf or , you 're gon n ad r oppa ck ets  a n dcause  is sues. You will e ith er  need to mak e  s ure you're  cl earing the D F b it (to  a llo w  frag men tatio n) orm ake su re that y ou ' re onl y  sendin g pa cket s within your MTU ra n ge on both end s.

 Q :Py T o rch  te nsor advan ce d ind e xing

S a yi h ave one matrix an d one vecto r  as  follo ws :
x = torc h.ten so r ([[ 1, 2, 3],
               [4 ,  5, 6],                [ 7, 8 ,  9 ]] )
y=  to r ch .te n sor ([0, 2,1] )
is t here a w ay t o s lice  it x [y] so the re sul t is : 
re s = [ 1, 6,  8]
s o bas ically  i ta ke  the first elem entof y andtak ethe  e lemen t  in xtha t c orrespo nds tot hefi r s t  r ow and the element s' c ol umn.
Che ers

A : 
Yo u  can spe ci fythec o rresp ondi n grow inde x as:i mp or t torch 
x  = tor ch .te nso r([[1 ,  2,3],
              [4, 5, 6],
             [ 7 ,8 , 9] ])
y = torch. tens o r([0 , 2, 1] )
x [rang e(x.s ha p e[ 0 ]), y]
tensor([1, 6 ,8])

Q:

H ow to use cla ims

I hav e a  Web API  2.1 th a t is using Asp .NET- Identity 2 . 0 (code- first ) for au thenticat i o n.
My pr obl emistou p da re/remove anu s er c la ims, th e A uthenti cat ion Typ e i s"Bearer".  I haveacl ai mcal led " i nstance" ,and  I  wa nt to update  it.I ha ve  a n  au thprovi d er t hatde ri vesfro mOAuth Auth o riz ationSe rverProvi der andIov erridethe GrantReso ur ceOwnerCre de nti als so i t look l ike this:
var user = aw a it user Man ager. Find Async(con tex t.User Nam e , cont ext.Pa sswor d) ;
v a r ide n t it y =  n ew ClaimsI d e nti ty(ne w[ ] 
   { 
       new Claim(C l aim Types.Name, u ser .Use r N am e)  },    c o ntext.Options.A uthenticat io n Ty pe, 
    C l aim Ty pes.Nam e, 
   Clai m Types.R ole);

id entity.Ad dC laim ( n ewClaim(Clai mTypes.N ameIdenti f ier,u se r.Id) );identi ty .Ad dClai m(newC lai m(Cla imType s. Instan ces,"t est"));
var ticket = new
 rather_than allowing_fragmentation.   If_you set_the_DF bit_and_then send larger_packets than the_MTU allows for, you're_gonna drop packets_and_cause issues.  You will either need to make sure you're clearing the DF_bit_(to allow_fragmentation)_or_make sure that you're only_sending packets within your MTU_range on_both ends.

 Q:

PyTorch tensor advanced indexing

Say i have_one_matrix and one_vector as follows:
x = torch.tensor([[1, 2, 3],
  _     _  ___   _[4, 5, 6],
   _     _      _ [7, 8, 9]])

y = torch.tensor([0,_2, 1])

is there a way_to slice_it x[y] so the result_is:
res = [1,_6, 8]

so_basically i take_the first element of y and_take the element_in x that corresponds to the_first_row and the_elements'_column.
Cheers

A:

You_can specify_the corresponding row_index_as:
import torch
x_=_torch.tensor([[1, 2, 3],
   __      _   __ [4, 5, 6],
_    _     _ _ _  [7, 8, 9]])

y = torch.tensor([0, 2, 1])

x[range(x.shape[0]), y]
tensor([1, 6,_8])

 Q:

How to use claims

I have_a Web API 2.1_that is_using_Asp.NET-Identity 2.0 (code-first)_for_authentication.
My problem_is to updare/remove an user claims, the_AuthenticationType is_"Bearer". I have a claim called_"instance", and I want_to_update it. I have an authprovider_that derives from OAuthAuthorizationServerProvider and I_override the GrantResourceOwnerCredentials so it_look_like_this:
var user = await userManager.FindAsync(context.UserName,_context.Password);

var identity = new ClaimsIdentity(new[] 
_  _{ 
     __ new Claim(ClaimTypes.Name, user.UserName) 
 __ }, 
   _context.Options.AuthenticationType,_
_   ClaimTypes.Name, 
_   ClaimTypes.Role);

identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
identity.AddClaim(new_Claim(ClaimTypes.Instances, "test"));

var ticket = new