系统找不到指定的路径:我是否可以通过调整导入的模块变量,设置环境变量或其他方法来解决?

时间:2019-05-07 23:04:41

标签: python-3.x keras

我一直在跟着一个教程进行学习,该教程让我加载一个模型来更改最后一个激活层,然后将那些更改应用于先前的模型(保存新模型?)。我的问题是我是否必须更改模块文件路径(如果是,那么如何从导入的模块中执行此操作)还是必须确保设置了环境变量?还是其他?

        cumulative = [go.Scatter(y=self.gb[self.y_column],
                                x=self.gb.index,
                                name='Cumulative',
                                hoverinfo='x+y',
                                hovertemplate="Month: %{x} <br>Cumulative Meter " + self.units + ": %{y}",
                                fill='tozeroy',
                                fillcolor=self.fill_color,
                                line={'color': self.cum_line_color,}
                                )]

        scatters = cumulative + scatters

错误

from keras.applications import VGG16
model = VGG16(weights='imagenet', include_top=True)

layers_info = {}
for i in model.layers:
    layers_info[i.name] = i.get_config()

layer_weights = {}
for i in model.layers:
    layer_weights[i.name] = i.get_weights()

#importing the required modules
from vis.visualization import visualize_activation
from vis.utils import utils
from keras import activations
from keras import applications
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (18,6)

layer_idx = utils.find_layer_idx(model,'predictions')

#changing the activation of the layer to linear
model.layers[layer_idx].activation = activations.linear

#applying modifications to the model
model = utils.apply_modifications(model)

1 个答案:

答案 0 :(得分:0)

我假设/ tmp /文件夹丢失。尝试在{{1}}前面添加句点,或者先创建文件夹。