• LABBOO
  • NEWBIE
  • 94 Points
  • Member since 2016
  • SF Admin
  • Lynda B Kane


  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 23
    Replies
Hi,

I'm trying to complete the "Use Apex in Transaction Security Policies" Challenge.

I think i have to modify this apex class : 
1 global class NewUrlPolicyCondition implements TxnSecurity.PolicyCondition {
2
3  public boolean evaluate(TxnSecurity.Event e) {
4
5  return false; 
6 }
7  }

The problem is that I know nothing about code, class or whatever. 
Can someone tell me how to set a condition ? 

Thanks. 
I'm at the step to Create the Orchestration in Salesforce but when I get to the page, I see the header but I can't see the Add Variable button at the lower left of my browser is a javascript:void(0) - can anyone give me something to try to resolve this?
  • February 02, 2019
  • Like
  • 0
I'm working on the Word Meaning and Word2vec badge and the Hands-on: Construct examples for each W2V variant is taking forever (it's already been running for 2 hours).  Has anyone else gotten through this?  How long did this part take?

My best guess is that I have something wrong but I'm not sure what since I've gotten no error messages...but when I stoped it it looks like it's still in the while loop - do can anyone provide some guidance on where I'm wrong and what I might want to look at to get back on track?

while True:
    # TODO: select a random sentence index using random.randint and get that
    # sentence. Be careful to avoid indexing errors.
    sentence_idx = random.randint(0,len(numericalized_sentences)-1)
    sentence = numericalized_sentences[sentence_idx]
    # TODO: Select a random window index using random.randint
    # and obtain that window of size n. Be careful to avoid indexing errors.
    window_idx = random.randint(0,len(sentence)-1)
    window = sentence[window_idx:k]
    
    if len(window) <= n//2:
      continue

Thanks!
Lynda

 
  • January 02, 2019
  • Like
  • 1
I'm really stuck on this one.

For the first part I have:
torch.manual_seed(123)

# TODO: Generate 2 clusters of 100 2d vectors, each one distributed normally, using
# only two calls of randn()
classApoints = torch.randn(100,2)
classBpoints = torch.randn(100,2)
#println(classApoints)

# TODO: Add the vector [1.0,3.0] to the first cluster and [3.0,1.0] to the second.
classApoints += torch.tensor([1.0,3.0])
classBpoints += torch.tensor([3.0,1.0])
#println(classApoints)

# TODO: Concatenate these two clusters along dimension 0 so that the points
# distributed around [1.0, 3.0] all come first
inputs = torch.cat([classApoints, classBpoints],0)
#println(inputs) - I suspect U might be missing something in here but I'm not certain

# TODO: Create a tensor of target values, 0 for points for the first cluster and
# 1 for the points in the second cluster. Make sure that these are LongTensors.
classA = classApoints.zero_().long()
classB = classBpoints.fill_(1).long()
targets = torch.cat([classA, classB])
#println(targets.type()) - pretty sure this is correct and I've confirmed they are LongTensors

For the 2nd part (where I'm having error) I've got:
# TODO: Set the random seed to 123 using manual_seed
torch.manual_seed(123)


# TODO: Initialize a Linear layer to output scores 
# for each class given the 2d examples
model = nn.Linear(2, 2)

# TODO: Define your loss function
loss_fn = nn.NLLLoss()

# TODO: Initialize an SGD optimizer with learning rate 0.1
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)

# Train the model for 100 epochs 
n_epochs = 1
losses = []
for _ in range(n_epochs):
  optimizer.zero_grad() 
  preds = model(inputs)
  #println(preds)
  #println(targets)
  loss = loss_fn(preds, targets)
  losses.append(loss)
  loss.backward()
  optimizer.step()
print(f'Anwswer to Exercise 6: Loss after {n_epochs} epochs: {losses[-1]}')
      
iterations = np.arange(len(losses))
_ = plt.plot(iterations, losses, '', iterations, losses, '-')

The error I'm getting:
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) <ipython-input-65-b59a439a8791> in <module>() 20 #println(preds) 21 #println(targets) ---> 22 loss = loss_fn(preds, targets) 23 losses.append(loss) 24 loss.backward() /usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs) 489 result = self._slow_forward(*input, **kwargs) 490 else: --> 491 result = self.forward(*input, **kwargs) 492 for hook in self._forward_hooks.values(): 493 hook_result = hook(self, input, result) /usr/local/lib/python3.6/dist-packages/torch/nn/modules/loss.py in forward(self, input, target) 191 _assert_no_grad(target) 192 return F.nll_loss(input, target, self.weight, self.size_average, --> 193 self.ignore_index, self.reduce) 194 195 /usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce) 1330 .format(input.size(0), target.size(0))) 1331 if dim == 2: -> 1332 return torch._C._nn.nll_loss(input, target, weight, size_average, ignore_index, reduce) 1333 elif dim == 4: 1334 return torch._C._nn.nll_loss2d(input, target, weight, size_average, ignore_index, reduce) RuntimeError: multi-target not supported at /pytorch/aten/src/THNN/generic/ClassNLLCriterion.c:22

Can anyone assist on this?
  • December 28, 2018
  • Like
  • 0
I'm working on the Word Meaning and Word2vec badge and the Hands-on: Construct examples for each W2V variant is taking forever (it's already been running for 2 hours).  Has anyone else gotten through this?  How long did this part take?

My best guess is that I have something wrong but I'm not sure what since I've gotten no error messages...but when I stoped it it looks like it's still in the while loop - do can anyone provide some guidance on where I'm wrong and what I might want to look at to get back on track?

while True:
    # TODO: select a random sentence index using random.randint and get that
    # sentence. Be careful to avoid indexing errors.
    sentence_idx = random.randint(0,len(numericalized_sentences)-1)
    sentence = numericalized_sentences[sentence_idx]
    # TODO: Select a random window index using random.randint
    # and obtain that window of size n. Be careful to avoid indexing errors.
    window_idx = random.randint(0,len(sentence)-1)
    window = sentence[window_idx:k]
    
    if len(window) <= n//2:
      continue

Thanks!
Lynda

 
  • January 02, 2019
  • Like
  • 1
I'm at the step to Create the Orchestration in Salesforce but when I get to the page, I see the header but I can't see the Add Variable button at the lower left of my browser is a javascript:void(0) - can anyone give me something to try to resolve this?
  • February 02, 2019
  • Like
  • 0
I'm working on the Word Meaning and Word2vec badge and the Hands-on: Construct examples for each W2V variant is taking forever (it's already been running for 2 hours).  Has anyone else gotten through this?  How long did this part take?

My best guess is that I have something wrong but I'm not sure what since I've gotten no error messages...but when I stoped it it looks like it's still in the while loop - do can anyone provide some guidance on where I'm wrong and what I might want to look at to get back on track?

while True:
    # TODO: select a random sentence index using random.randint and get that
    # sentence. Be careful to avoid indexing errors.
    sentence_idx = random.randint(0,len(numericalized_sentences)-1)
    sentence = numericalized_sentences[sentence_idx]
    # TODO: Select a random window index using random.randint
    # and obtain that window of size n. Be careful to avoid indexing errors.
    window_idx = random.randint(0,len(sentence)-1)
    window = sentence[window_idx:k]
    
    if len(window) <= n//2:
      continue

Thanks!
Lynda

 
  • January 02, 2019
  • Like
  • 1
I'm really stuck on this one.

For the first part I have:
torch.manual_seed(123)

# TODO: Generate 2 clusters of 100 2d vectors, each one distributed normally, using
# only two calls of randn()
classApoints = torch.randn(100,2)
classBpoints = torch.randn(100,2)
#println(classApoints)

# TODO: Add the vector [1.0,3.0] to the first cluster and [3.0,1.0] to the second.
classApoints += torch.tensor([1.0,3.0])
classBpoints += torch.tensor([3.0,1.0])
#println(classApoints)

# TODO: Concatenate these two clusters along dimension 0 so that the points
# distributed around [1.0, 3.0] all come first
inputs = torch.cat([classApoints, classBpoints],0)
#println(inputs) - I suspect U might be missing something in here but I'm not certain

# TODO: Create a tensor of target values, 0 for points for the first cluster and
# 1 for the points in the second cluster. Make sure that these are LongTensors.
classA = classApoints.zero_().long()
classB = classBpoints.fill_(1).long()
targets = torch.cat([classA, classB])
#println(targets.type()) - pretty sure this is correct and I've confirmed they are LongTensors

For the 2nd part (where I'm having error) I've got:
# TODO: Set the random seed to 123 using manual_seed
torch.manual_seed(123)


# TODO: Initialize a Linear layer to output scores 
# for each class given the 2d examples
model = nn.Linear(2, 2)

# TODO: Define your loss function
loss_fn = nn.NLLLoss()

# TODO: Initialize an SGD optimizer with learning rate 0.1
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)

# Train the model for 100 epochs 
n_epochs = 1
losses = []
for _ in range(n_epochs):
  optimizer.zero_grad() 
  preds = model(inputs)
  #println(preds)
  #println(targets)
  loss = loss_fn(preds, targets)
  losses.append(loss)
  loss.backward()
  optimizer.step()
print(f'Anwswer to Exercise 6: Loss after {n_epochs} epochs: {losses[-1]}')
      
iterations = np.arange(len(losses))
_ = plt.plot(iterations, losses, '', iterations, losses, '-')

The error I'm getting:
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) <ipython-input-65-b59a439a8791> in <module>() 20 #println(preds) 21 #println(targets) ---> 22 loss = loss_fn(preds, targets) 23 losses.append(loss) 24 loss.backward() /usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs) 489 result = self._slow_forward(*input, **kwargs) 490 else: --> 491 result = self.forward(*input, **kwargs) 492 for hook in self._forward_hooks.values(): 493 hook_result = hook(self, input, result) /usr/local/lib/python3.6/dist-packages/torch/nn/modules/loss.py in forward(self, input, target) 191 _assert_no_grad(target) 192 return F.nll_loss(input, target, self.weight, self.size_average, --> 193 self.ignore_index, self.reduce) 194 195 /usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in nll_loss(input, target, weight, size_average, ignore_index, reduce) 1330 .format(input.size(0), target.size(0))) 1331 if dim == 2: -> 1332 return torch._C._nn.nll_loss(input, target, weight, size_average, ignore_index, reduce) 1333 elif dim == 4: 1334 return torch._C._nn.nll_loss2d(input, target, weight, size_average, ignore_index, reduce) RuntimeError: multi-target not supported at /pytorch/aten/src/THNN/generic/ClassNLLCriterion.c:22

Can anyone assist on this?
  • December 28, 2018
  • Like
  • 0
Create the package version - Step 5
Error Attempt to create unlocked pkg step 5
Following Error:
ERROR:  An unexpected error occurred. Please contact Salesforce Support and provide the following error code: 1394095453-59495 (-1373703285).

Anyone know what this is?
DevHub set up; Packaging2 Beta enabled in DevHub; and I have an active GitHub account.
I'm struggling with the custom lightning component on this part. I don't have much background coding and am having trouble finding resources to help me achieve coding the lightning component. If someone could help give me some framework code to create a custom lightning component to hold a URL or direct me to a resource that help break this down I'd be very appreciative.
 
I am facing another issue on this superbadge, specifically in Challenge #10, i am getting the following error:
The Campaign Influence Lightning report must have the correct 1. Aggregate, 2. Columns, 3. Groupings, and 4. Filter.

The requirements have no mention about what fields, groupings, filters, aggregates to include in the report. What am I missing?