File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 1515 "metadata" : {},
1616 "outputs" : [],
1717 "source" : [
18- " ! pip install codebook-features\n " ,
19- " # restart runtime after installing if running on Colab\n " ,
20- " from IPython import get_ipython\n " ,
18+ " try:\n " ,
19+ " import codebook_features\n " ,
20+ " except:\n " ,
21+ " ! pip install codebook-features\n " ,
22+ " # restart runtime after installing if running on Colab\n " ,
23+ " from IPython import get_ipython\n " ,
2124 " \n " ,
22- " if \" google.colab\" in str(get_ipython()):\n " ,
23- " exit(0)"
25+ " if \" google.colab\" in str(get_ipython()):\n " ,
26+ " exit(0)"
2427 ]
2528 },
2629 {
106109 "source" : [
107110 " sentence = \" this is a random sentence to test.\"\n " ,
108111 " input_tensor = tokenizer(sentence, return_tensors=\" pt\" )[\" input_ids\" ]\n " ,
112+ " input_tensor = input_tensor.to(device)\n " ,
109113 " output = orig_cb_model(input_tensor)[\" logits\" ]\n " ,
110114 " hooked_output = cb_model(input_tensor)\n " ,
111115 " assert torch.allclose(output, hooked_output, atol=1e-4)"
You can’t perform that action at this time.
0 commit comments