以下是在优化过程中尝试使用输入图像作为训练变量的代码。它从 keras 模型开始,并将其转换为 tensorflow 模型。该张量流模型以张量作为输入,并尝试使用输入张量作为可训练变量来优化成本函数。
错误是:
NotImplementedError: ('试图更新张量', )
原因是输入张量不是变量。问题是如何使输入图像可训练或将张量转换为 tf.variable。帮助表示赞赏:
import tensorflow as tf
from keras.models import Sequential, load_model, Model
from keras import backend as K
from keras.layers.core import Dense, Dropout, Activation
import os
from tensorflow.python.framework import graph_util
from tensorflow.python.framework import graph_io
n_classes = 10
model = Sequential()
model.add(Dense(10, input_shape=(784,)))
model.add(Activation('relu'))
model.add(Dense(n_classes, name='logits'))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy', metrics=['accuracy'], optimizer='adam')
# Write the graph in binary .pb file
outdir = "model4_tf"
try:
os.mkdir(outdir )
except:
pass
prefix = "simple_nn"
name = 'output_graph.pb' …Run Code Online (Sandbox Code Playgroud) 我可以安装一个特定的文件。在同一命令中使用通配符时,它会抱怨该文件不存在。
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libproduction_rdict.pcm DESTINATION ${LIBRARY_OUTPUT_PATH})
Run Code Online (Sandbox Code Playgroud)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/*_rdict.pcm DESTINATION ${LIBRARY_OUTPUT_PATH})
Run Code Online (Sandbox Code Playgroud)
错误信息是:
-- Install configuration: ""
CMake Error at Source/cmake_install.cmake:49 (file):
file INSTALL cannot find
"/home/wxie/AI/CUDA/cuda_exmaple/example_2/Build/Source/*_rdict.pcm".
Call Stack (most recent call first):
cmake_install.cmake:42 (include)
Run Code Online (Sandbox Code Playgroud)