尝试使用 中的hub.load
函数时tensorflow_hub
,出现OSError: SavedModel file does not exist at:
错误。
奇怪的是,它在几天前起作用了,所以我不太明白为什么我现在会收到这个错误。
重现代码:
import tensorflow as tf
import tensorflow_hub as hub
URL = 'https://tfhub.dev/google/universal-sentence-encoder/4'
embed = hub.load(URL)
Run Code Online (Sandbox Code Playgroud)
收到的具体错误:
OSError Traceback (most recent call last)
<ipython-input-11-dfb80f0299b2> in <module>
1 URL = 'https://tfhub.dev/google/universal-sentence-encoder/4'
----> 2 embed = hub.load(URL)
~/opt/anaconda3/lib/python3.7/site-packages/tensorflow_hub/module_v2.py in load(handle, tags)
100 if tags is None and is_hub_module_v1:
101 tags = []
--> 102 obj = tf_v1.saved_model.load_v2(module_path, tags=tags)
103 obj._is_hub_module_v1 = is_hub_module_v1 # pylint: disable=protected-access
104 return obj …
Run Code Online (Sandbox Code Playgroud) 我有一个具有44列的数据框(df),我想重命名2:44列。我有一个长度为42的列表(namesList),其中包含新的列名。然后,我尝试使用列表重命名我的列:
df.columns[2:len(df.columns)] = namesList
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误:
TypeError:索引不支持可变操作
为什么会出现此错误?
假设我知道每月增长率是 5%,并且我知道 2018 年 1 月的基数是 1000。如何创建一个长度为 12 的向量,它显示 2018 年的每月总数?例如,向量中的前四个元素将是:
c(1000, 1000*1.05, 1000*1.05^2, 1000*1.05^3)
有没有一个功能可以让我轻松地做到这一点?我正在考虑以rep()
某种方式使用该功能。