# 该方法用于比较两个tensor是否一样,一样则返回True否则为False a = torch.tensor([1,2,3,4]) b = torch.tensor([1,2,3,4]) print(a.equal(b)) # 返回True
tensor.eq()方法
1 2 3 4
# 该方法用于主元素比较是否相等,相等则在对应位置返回True,否则为False a = torch.tensor([1,2,2,3]) b = torch.tensor([2,2,3,3]) print(a.eq(b)) # 返回tensor([False,True,False,True]),与a==b返回的结果一样
pytorch输出整个tensor的方法
1 2 3 4
torch.set_printoptions(profile="full") print(x) # prints the whole tensor torch.set_printoptions(profile="default") # reset print(x) # prints the truncated tensor
input: 当batch_first = False的时候(L, N, H_in),当batch_first=True的时候(N, L, H_in) h_0: (D*num_layers, N, H_out),containing the initial hidden state for each element in the batch. Defaults to zeros if (h_0, c_0) isnot provided. c_0: (D*num_layers, N, H_cell),containing the initial cell state for each element in the batch. Defaults to zeros if (h_0, c_0) isnot provided.
output: 当batch_first=False的时候是(L, N, D*H_out),当batch_first=True的时候是(N, L, D*H_out),其中包括了LSTM最后一层的输出h_t,对于每个t时刻。在PackedSequence相关上还有其他的操作,不过暂时就先不管了 h_n: (D*num_layers, N, H_out)包含了每个batch中最后的一个hidden state的element c_n: (D*num_layersm N, H_cell)包含了最后一个cell的state,对于每个batch的最后一个element?
$ pip install tensorboard ... (venvsumbt) lyx@h1:/hdd1/lyx$ tensorboard TensorFlow installation not found - running with reduced feature set. Error: A logdir or db must be specified. For example `tensorboard --logdir mylogdir` or `tensorboard --db sqlite:~/.tensorboard.db`. Run `tensorboard --helpfull` for details and examples.
使用方法如下(SUMBT-lyx为例):
1 2 3 4 5 6 7 8 9
(venvsumbt) lyx@h1:/hdd1/lyx/SUMBT-lyx$ tensorboard --logdir='SUMBT-lyx/tensorboard/output' TensorFlow installation not found - running with reduced feature set.
NOTE: Using experimental fast data loading logic. To disable, pass "--load_fast=false" and report issues on GitHub. More details: https://github.com/tensorflow/tensorboard/issues/4784
Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all TensorBoard 2.7.0 at http://localhost:6007/ (Press CTRL+C to quit)
deftoken_sort_ratio(s1, s2, force_ascii=True, full_process=True): """Return a measure of the sequences' similarity between 0 and 100 but sorting the token before comparing. """ return _token_sort(s1, s2, partial=False, force_ascii=force_ascii, full_process=full_process)
# utils.full_process deffull_process(s, force_ascii=False): """Process string by -- removing all but letters and numbers -- trim whitespace -- force to lower case if force_ascii == True, force convert to ascii 这里是几种字符过滤方式, """ if force_ascii: s = asciidammit(s) # Keep only Letters and Numbers (see Unicode docs). string_out = StringProcessor.replace_non_letters_non_numbers_with_whitespace(s) # 用空格替代所有不是字母和数字的 # Force into lowercase. string_out = StringProcessor.to_lower_case(string_out) # Remove leading and trailing whitespaces. string_out = StringProcessor.strip(string_out) return string_out