//缩放imageData,scale:倍数,返回:imageData functionscaleImageData(imageData, scale) { var scaled = ctx.createImageData(imageData.width * scale, imageData.height * scale); for (var row = 0; row < imageData.height; row++) { for (var col = 0; col < imageData.width; col++) { var sourcePixel = [ imageData.data[(row * imageData.width + col) * 4 + 0], imageData.data[(row * imageData.width + col) * 4 + 1], imageData.data[(row * imageData.width + col) * 4 + 2], imageData.data[(row * imageData.width + col) * 4 + 3] ]; for (var y = 0; y < scale; y++) { var destRow = Math.floor(row * scale) + y; for (var x = 0; x < scale; x++) { var destCol = Math.floor(col * scale) + x; for (var i = 0; i < 4; i++) { scaled.data[(destRow * scaled.width + destCol) * 4 + i] = sourcePixel[i]; } } } } } // alert(scaled.data.length); return scaled; }
获取服务器的ip
这里取巧了,直接从浏览器显示部分获取 代码如下:
1 2 3 4 5 6 7 8
//获取服务器ip,运行时urlPath为https://192.168.137.1:8000/ function getRemoteIp(){ var urlPath = window.document.location.href; //浏览器显示地址 http://10.15.5.83:5555/ISV/demo.aspx?a=1&b=2 // var docPath = window.document.location.pathname; //文件在服务器相对地址 /ISV/demo.aspx // var index = urlPath.indexOf(docPath); var serverPath = urlPath.substring(7, urlPath.length-1);//服务器ip 192.168.137.1 return serverPath; }
# 用数据测试模型 with tf.Session() as sess: # get_checkoutpoint_state()会通过checkoutpoint文件自动找到目录中最新模型的文件名 ckpt = tf.train.get_checkpoint_state(mnist_train.MODEL_PATH) if ckpt and ckpt.model_checkpoint_path: # 加载模型 saver.restore(sess, ckpt.model_checkpoint_path)
报错:Error: the tensor’s graph is different from the session’s graph
这是因为session里面的图和使用的图不一样导致的,刚开始不清楚,把参考的博客上面的那句: with tf.Graph().as_default() as g:写上去了,导致默认图被设置成了g,但是用的又是恢复的图,所以不一样了
解决办法炒鸡简单…但是debug的过程里就一直没意识到就是了…就是把那句话去掉就行了哇
报错:List of Tensors when single Tensor expected
使用tf.constant()函数的时候可能会报这个错误
看看这个函数的定义:
def constant(value, dtype=None, shape=None, name=”Const”, verify_shape=False) value: A constant value (or list) of output type dtype. Returns: A Constant Tensor.