看起来get_latest_training_loss函数fasttext只返回0。gensim 4.1.0和4.0.0都不起作用。
from gensim.models.callbacks import CallbackAny2Vec
from pprint import pprint as print
from gensim.models.fasttext import FastText
from gensim.test.utils import datapath
class callback(CallbackAny2Vec):
'''Callback to print loss after each epoch.'''
def __init__(self):
self.epoch = 0
def on_epoch_end(self, model):
loss = model.get_latest_training_loss()
print('Loss after epoch {}: {}'.format(self.epoch, loss))
self.epoch += 1
# Set file names for train and test data
corpus_file = datapath('lee_background.cor')
model = FastText(vector_size=100, callbacks=[callback()])
# build the vocabulary
model.build_vocab(corpus_file=corpus_file)
# train …Run Code Online (Sandbox Code Playgroud) array nexb nexb:; array nexo nexo:; array sexb sexb:; array sexo sexo:;
Run Code Online (Sandbox Code Playgroud)
我想知道声明array nexb nexb:;在这里做了什么?
似乎在R中,我可以引用带有变量名称一部分的变量.但我很困惑为什么我能做到这一点.
使用以下代码作为示例:
library(car)
scatterplot(housing ~ total)
house.lm <- lm(housing ~ total)
summary(house.lm)
str(summary(house.lm))
summary(house.lm)$coefficients[2,2]
summary(house.lm)$coe[2,2]
Run Code Online (Sandbox Code Playgroud)
当我打印摘要(house.lm)的结构时,我得到以下输出:
> str(summary(house.lm))
List of 11
$ call : language lm(formula = housing ~ total)
$ terms :Classes 'terms', 'formula' language housing ~ total
.. ..- attr(*, "variables")= language list(housing, total)
.. ..- attr(*, "factors")= int [1:2, 1] 0 1
.. .. ..- attr(*, "dimnames")=List of 2
.. .. .. ..$ : chr [1:2] "housing" "total"
.. .. .. ..$ : chr "total"
.. ..- …Run Code Online (Sandbox Code Playgroud) 如果在此处查看grf软件包,您会注意到它具有三个版本:
似乎r-devel是开发版本,r-release是发行版本,r-olderel是旧版本。但是,很奇怪的是它们共享完全相同的版本号0.10.2。如果版本不同,他们为什么不更改版本号?
我使用以下代码从数据集创建一个数组:
DATA REPLACED;
SET TPS_DROPPED;
array arr_jin(*) _numeric_;
do i=1 to dim(arr_jin);
if arr_jin(i) = . then arr_jin(i) = 0;
end;
drop i arr_jin;
RUN;
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误日志:
ERROR 241-185: The array arr_jin is not allowed in a DROP/KEEP/RENAME context.
WARNING: The variable arr_jin in the DROP, KEEP, or RENAME list has never been referenced.
Run Code Online (Sandbox Code Playgroud)
通常在创建后不需要删除数组吗?
我使用以下代码在某个条件下从数据集中删除一些行:
data MK_RETURN;
/*delete some data to solve the beta zero problem*/
if CUM_RETURN<RMIN then delete;
run;
Run Code Online (Sandbox Code Playgroud)
但是,我发现数据集MK_RETURN不仅变空,而且还缺少所有变量但CUM_RETURN并返回.
在删除操作之前,数据集包含六到七个变量.但是在删除操作之后,数据集只包含两个(空变量),即CUM_RETURN,RMIN.
这有什么不对?
输入数据就像
+--------+----------+------+--------------+--------------+-------------+----------+----------------+
| SYMBOL | DATE | time | CUM_RETURN | return_sec | RMIN | one_M | MK_RETURN_RATE |
+--------+----------+------+--------------+--------------+-------------+----------+----------------+
| A | 20130108 | 1 | 0 | | 0.00023571 | 1.90E-11 | 3.130243764 |
| A | 20130108 | 2 | | -0.00117855 | 0.000235988 | 1.90E-11 | 0.000274509 |
| A | 20130108 | 3 | 0.000471976 …Run Code Online (Sandbox Code Playgroud) 我试图解码类似于以下格式的十六进制字符串:
0x00000000000000000000000000000000000000000000000bf97e2a21966df7fe
Run Code Online (Sandbox Code Playgroud)
我能够使用在线计算器对其进行解码.应该是正确的解码数字220892037897060743166.
但是,当我尝试使用python使用以下代码对其进行解码时,它会返回错误:
"0x00000000000000000000000000000000000000000000000bf97e2a21966df7fe".decode("hex")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-32-1cf86ff46cbc> in <module>()
9 key=keyarr[0]
10
---> 11 "0x00000000000000000000000000000000000000000000000bf97e2a21966df7fe".decode("hex")
/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/hex_codec.py in hex_decode(input, errors)
40 """
41 assert errors == 'strict'
---> 42 output = binascii.a2b_hex(input)
43 return (output, len(input))
44
TypeError: Non-hexadecimal digit found
Run Code Online (Sandbox Code Playgroud)
然后我删除了十六进制数字前面的0x并再次尝试:
"00000000000000000000000000000000000000000000000bf97e2a21966df7fe".decode("hex")
Run Code Online (Sandbox Code Playgroud)
然后输出成为:
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b\xf9~*!\x96m\xf7\xfe'
Run Code Online (Sandbox Code Playgroud)
我实际上不明白输出...
如果您想知道这些数字来自何处,它们来自以太坊区块链(ERC20)令牌.