Invalid JSON:Unexpected non-whitespace character after JSONat line 2, column 1
| {"QuestionId": 37332448, "AnswerCount": 0, "Tags": "<machine-learning><neural-network><tensorflow>", "CreationDate": "2016-05-19T19:30:05.003", "AcceptedAnswerId": null, "Title": "How do I determine the training \"accuracy\" for a TensorFlow network with dropout?", "Body": "<p>I'm <a href=\"https://stackoverflow.com/a/37102454/656912\">aware</a> that \"accuracy\" isn't what measured against the training set for a neural network during training, but I'd like to know, essentially</p>\n\n<blockquote>\n <p>what would happen if I stop trianing now and try to evaluate training set in terms of accuracy</p>\n</blockquote>\n\n<p>at various points during training of a TensorFlow network being trained with dropout. </p>\n\n<p>Can this question be answered simply by running with the training data and <code>keep_prob == 1.0</code>, that is with something like</p>\n\n<pre><code>sess.run(accuracy, feed_dict={x: train_x, y_: train_y, keep_prob: 1.0})\n</code></pre>\n", "Lable": "D"} | |
| {"QuestionId": 37374734, "AnswerCount": 1, "Tags": "<vba><excel-vba><csv><excel>", "CreationDate": "2016-05-22T13:04:52.660", "AcceptedAnswerId": "37375709", "Title": "Taking record from Excel and searching multiple records in .csv/.txt file using vba", "Body": "<p>I am looping through Excel (for example record city =\"Paris\") and then want to retrieve multiple records from .csv files (there could be possibility of retrieving multiple records available in .csv files pertaining to city paris) </p>\n\n<p>Here is be basic structure of .txt which tab delimited file.</p>\n\n<pre><code>1 Tokyo JA test Tokyo \"test, testttttttttt.\" \"images url to download delimited by ,\"\n2 Tokyo JA test Tokyo \"test, testttttttttt.\" \"images url to download delimited by ,\"\n3 Paris FR test Tokyo \"test, testttttttttt.\" \"images url to download delimited by ,\"\n</code></pre>\n\n<p>Can anybody help me with this, please note that above file is .txt file and having said that I want to know how many records are ( count ) met with per Excel records in the .txt/csv file so I want to do other activities required in my system. </p>\n\n<p>Here is my code :</p>\n\n<pre><code>currPath1 = \"C:\\sourceexcel.xlsx\"\n currentPath2 = \"C:\\CSVtoberead.txt\"\nfileNum =FreeFile()\n Open currentPath2 For Input As fileNum\n totoalRows= xlsheet.UsedRange.Rows.Count\n startrow1 =1\n PreviousCity=\"\"\n For x= startRow To totoalRows\n currentCity = xlsheet.Cells(startRow,3 ).value '' this is city from excel sheet\n Do While Not EOF( fileNum )\n Line Input #fileNum, txt '''file to read .txt file\n parseRecord = Split (txt,Chr(9))\n If parserecord(1)= currentCity Then \n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 37434201, "AnswerCount": 1, "Tags": "<function><go><var>", "CreationDate": "2016-05-25T10:20:24.517", "AcceptedAnswerId": "37434292", "Title": "How to assign an int returned by a function to a variable?", "Body": "<p>I am new to Go and having some issues with figuring out a really simple problem. I am learning by working through some simple problem sets and at the moment am trying to print the sequence of Fibonacci numbers that are smaller than 10 million. My Fibonacci function is fine but I am not sure how to assign its value to a variable which I can then use in control structures. For instance:</p>\n\n<pre><code>package main\n\nimport \"fmt\"\n\nfunc fib() func() int {\n x, y := 0, 1\n return func() int {\n x, y = y, x+y\n return x\n }\n}\n\nfunc main() {\n f := fib()\n for f <= 10000000 {\n fmt.Println(f())\n }\n}\n</code></pre>\n\n<p>I know I am missing something simple here but should this not keep calling my function and grabbing the next number in the Fibonacci sequence until that number is no greater than or equal to 10 million? I receive an error telling me there are mismatched types func() (int and int). I know this is dead simple and I am likely just an idiot.\nThanks in advance.</p>\n", "Lable": "No"} | |
| {"QuestionId": 37443237, "AnswerCount": 2, "Tags": "<python><computer-vision><deep-learning><caffe>", "CreationDate": "2016-05-25T16:48:26.407", "AcceptedAnswerId": null, "Title": "Display images with bounding boxes while running py-faster-rcnn using VGG_CNN_M_1024", "Body": "<p>I am using the <code>demo.py</code>given in <a href=\"https://github.com/rbgirshick/py-faster-rcnn/tree/master/tools\" rel=\"nofollow\">https://github.com/rbgirshick/py-faster-rcnn/tree/master/tools</a>.</p>\n\n<p>I have modified the code to run <code>VGG_CNN_M_1024</code> as I am using a 2GB GPU. And as per the comments given in <a href=\"https://github.com/rbgirshick/fast-rcnn/issues/2\" rel=\"nofollow\">https://github.com/rbgirshick/fast-rcnn/issues/2</a>, I chose to run <code>VGG_CNN_M_1024.caffemodel</code> instead of <code>VGG16_faster_rcnn_final.caffemodel</code> </p>\n\n<p>This is the code in <code>demo.py</code>:</p>\n\n<pre><code>#!/usr/bin/env python\n\n# --------------------------------------------------------\n# Faster R-CNN\n# Copyright (c) 2015 Microsoft\n# Licensed under The MIT License [see LICENSE for details]\n# Written by Ross Girshick\n# --------------------------------------------------------\n\n\"\"\"\nDemo script showing detections in sample images.\n\nSee README.md for installation instructions before running.\n\"\"\"\n\nimport _init_paths\nfrom fast_rcnn.config import cfg\nfrom fast_rcnn.test import im_detect\nfrom fast_rcnn.nms_wrapper import nms\nfrom utils.timer import Timer\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport scipy.io as sio\nimport caffe, os, sys, cv2\nimport argparse\n\nCLASSES = ('__background__',\n 'aeroplane', 'bicycle', 'bird', 'boat',\n 'bottle', 'bus', 'car', 'cat', 'chair',\n 'cow', 'diningtable', 'dog', 'horse',\n 'motorbike', 'person', 'pottedplant',\n 'sheep', 'sofa', 'train', 'tvmonitor')\n\nNETS = {'vgg16': ('VGG16',\n 'VGG16_faster_rcnn_final.caffemodel'),\n 'zf': ('ZF',\n 'ZF_faster_rcnn_final.caffemodel'),\n 'vgg16_m_1024':('VGG_CNN_M_1024','VGG_CNN_M_1024.caffemodel')}\n\n\ndef vis_detections(im, class_name, dets, thresh=0.5):\n \"\"\"Draw detected bounding boxes.\"\"\"\n inds = np.where(dets[:, -1] >= thresh)[0]\n if len(inds) == 0:\n return\n\n im = im[:, :, (2, 1, 0)]\n fig, ax = plt.subplots(figsize=(12, 12))\n ax.imshow(im, aspect='equal')\n for i in inds:\n bbox = dets[i, :4]\n score = dets[i, -1]\n\n ax.add_patch(\n plt.Rectangle((bbox[0], bbox[1]),\n bbox[2] - bbox[0],\n bbox[3] - bbox[1], fill=False,\n edgecolor='red', linewidth=3.5)\n )\n ax.text(bbox[0], bbox[1] - 2,\n '{:s} {:.3f}'.format(class_name, score),\n bbox=dict(facecolor='blue', alpha=0.5),\n fontsize=14, color='white')\n\n ax.set_title(('{} detections with '\n 'p({} | box) >= {:.1f}').format(class_name, class_name,\n thresh),\n fontsize=14)\n plt.axis('off')\n plt.tight_layout()\n plt.draw()\n\ndef demo(net, image_name):\n \"\"\"Detect object classes in an image using pre-computed object proposals.\"\"\"\n\n # Load the demo image\n im_file = os.path.join(cfg.DATA_DIR, 'demo', image_name)\n im = cv2.imread(im_file)\n\n # Detect all object classes and regress object bounds\n timer = Timer()\n timer.tic()\n scores, boxes = im_detect(net, im)\n timer.toc()\n print ('Detection took {:.3f}s for '\n '{:d} object proposals').format(timer.total_time, boxes.shape[0])\n\n # Visualize detections for each class\n CONF_THRESH = 0.8\n NMS_THRESH = 0.3\n for cls_ind, cls in enumerate(CLASSES[1:]):\n cls_ind += 1 # because we skipped background\n cls_boxes = boxes[:, 4*cls_ind:4*(cls_ind + 1)]\n cls_scores = scores[:, cls_ind]\n dets = np.hstack((cls_boxes,\n cls_scores[:, np.newaxis])).astype(np.float32)\n keep = nms(dets, NMS_THRESH)\n dets = dets[keep, :]\n vis_detections(im, cls, dets, thresh=CONF_THRESH)\n\ndef parse_args():\n \"\"\"Parse input arguments.\"\"\"\n parser = argparse.ArgumentParser(description='Faster R-CNN demo')\n parser.add_argument('--gpu', dest='gpu_id', help='GPU device id to use [0]',\n default=0, type=int)\n parser.add_argument('--cpu', dest='cpu_mode',\n help='Use CPU mode (overrides --gpu)',\n action='store_true')\n parser.add_argument('--net', dest='demo_net', help='Network to use [vgg16]',\n choices=NETS.keys(), default='vgg16_m_1024')\n\n args = parser.parse_args()\n\n return args\n\nif __name__ == '__main__':\n cfg.TEST.HAS_RPN = True # Use RPN for proposals\n\n args = parse_args()\n\n prototxt = os.path.join(cfg.MODELS_DIR, NETS[args.demo_net][0],\n 'faster_rcnn_alt_opt', 'faster_rcnn_test.pt')\n caffemodel = os.path.join(cfg.DATA_DIR, 'faster_rcnn_models',\n NETS[args.demo_net][1])\n\n if not os.path.isfile(caffemodel):\n raise IOError(('{:s} not found.\\nDid you run ./data/script/'\n 'fetch_faster_rcnn_models.sh?').format(caffemodel))\n\n if args.cpu_mode:\n caffe.set_mode_cpu()\n else:\n caffe.set_mode_gpu()\n caffe.set_device(args.gpu_id)\n cfg.GPU_ID = args.gpu_id\n net = caffe.Net(prototxt, caffemodel, caffe.TEST)\n\n print '\\n\\nLoaded network {:s}'.format(caffemodel)\n\n # Warmup on a dummy image\n im = 128 * np.ones((300, 500, 3), dtype=np.uint8)\n for i in xrange(2):\n _, _= im_detect(net, im)\n\n im_names = ['000456.jpg', '000542.jpg', '001150.jpg',\n '001763.jpg', '004545.jpg']\n for im_name in im_names:\n print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'\n print 'Demo for data/demo/{}'.format(im_name)\n demo(net, im_name)\n\n plt.show()\n</code></pre>\n\n<p>And this is <code>config.py</code></p>\n\n<pre><code># --------------------------------------------------------\n# Fast R-CNN\n# Copyright (c) 2015 Microsoft\n# Licensed under The MIT License [see LICENSE for details]\n# Written by Ross Girshick\n# --------------------------------------------------------\n\n\"\"\"Fast R-CNN config system.\n\nThis file specifies default config options for Fast R-CNN. You should not\nchange values in this file. Instead, you should write a config file (in yaml)\nand use cfg_from_file(yaml_file) to load it and override the default options.\n\nMost tools in $ROOT/tools take a --cfg option to specify an override file.\n - See tools/{train,test}_net.py for example code that uses cfg_from_file()\n - See experiments/cfgs/*.yml for example YAML config override files\n\"\"\"\n\nimport os\nimport os.path as osp\nimport numpy as np\n# `pip install easydict` if you don't have it\nfrom easydict import EasyDict as edict\n\n__C = edict()\n# Consumers can get config by:\n# from fast_rcnn_config import cfg\ncfg = __C\n\n#\n# Training options\n#\n\n__C.TRAIN = edict()\n\n# Scales to use during training (can list multiple scales)\n# Each scale is the pixel size of an image's shortest side\n__C.TRAIN.SCALES = (600,)\n\n# Max pixel size of the longest side of a scaled input image\n__C.TRAIN.MAX_SIZE = 1000\n\n# Images to use per minibatch\n__C.TRAIN.IMS_PER_BATCH = 2\n\n# Minibatch size (number of regions of interest [ROIs])\n__C.TRAIN.BATCH_SIZE = 128\n\n# Fraction of minibatch that is labeled foreground (i.e. class > 0)\n__C.TRAIN.FG_FRACTION = 0.25\n\n# Overlap threshold for a ROI to be considered foreground (if >= FG_THRESH)\n__C.TRAIN.FG_THRESH = 0.5\n\n# Overlap threshold for a ROI to be considered background (class = 0 if\n# overlap in [LO, HI))\n__C.TRAIN.BG_THRESH_HI = 0.5\n__C.TRAIN.BG_THRESH_LO = 0.1\n\n# Use horizontally-flipped images during training?\n__C.TRAIN.USE_FLIPPED = True\n\n# Train bounding-box regressors\n__C.TRAIN.BBOX_REG = True\n\n# Overlap required between a ROI and ground-truth box in order for that ROI to\n# be used as a bounding-box regression training example\n__C.TRAIN.BBOX_THRESH = 0.5\n\n# Iterations between snapshots\n__C.TRAIN.SNAPSHOT_ITERS = 10000\n\n# solver.prototxt specifies the snapshot path prefix, this adds an optional\n# infix to yield the path: <prefix>[_<infix>]_iters_XYZ.caffemodel\n__C.TRAIN.SNAPSHOT_INFIX = ''\n\n# Use a prefetch thread in roi_data_layer.layer\n# So far I haven't found this useful; likely more engineering work is required\n__C.TRAIN.USE_PREFETCH = False\n\n# Normalize the targets (subtract empirical mean, divide by empirical stddev)\n__C.TRAIN.BBOX_NORMALIZE_TARGETS = True\n# Deprecated (inside weights)\n__C.TRAIN.BBOX_INSIDE_WEIGHTS = (1.0, 1.0, 1.0, 1.0)\n# Normalize the targets using \"precomputed\" (or made up) means and stdevs\n# (BBOX_NORMALIZE_TARGETS must also be True)\n__C.TRAIN.BBOX_NORMALIZE_TARGETS_PRECOMPUTED = False\n__C.TRAIN.BBOX_NORMALIZE_MEANS = (0.0, 0.0, 0.0, 0.0)\n__C.TRAIN.BBOX_NORMALIZE_STDS = (0.1, 0.1, 0.2, 0.2)\n\n# Train using these proposals\n__C.TRAIN.PROPOSAL_METHOD = 'selective_search'\n\n# Make minibatches from images that have similar aspect ratios (i.e. both\n# tall and thin or both short and wide) in order to avoid wasting computation\n# on zero-padding.\n__C.TRAIN.ASPECT_GROUPING = True\n\n# Use RPN to detect objects\n__C.TRAIN.HAS_RPN = False\n# IOU >= thresh: positive example\n__C.TRAIN.RPN_POSITIVE_OVERLAP = 0.7\n# IOU < thresh: negative example\n__C.TRAIN.RPN_NEGATIVE_OVERLAP = 0.3\n# If an anchor statisfied by positive and negative conditions set to negative\n__C.TRAIN.RPN_CLOBBER_POSITIVES = False\n# Max number of foreground examples\n__C.TRAIN.RPN_FG_FRACTION = 0.5\n# Total number of examples\n__C.TRAIN.RPN_BATCHSIZE = 256\n# NMS threshold used on RPN proposals\n__C.TRAIN.RPN_NMS_THRESH = 0.7\n# Number of top scoring boxes to keep before apply NMS to RPN proposals\n__C.TRAIN.RPN_PRE_NMS_TOP_N = 12000\n# Number of top scoring boxes to keep after applying NMS to RPN proposals\n__C.TRAIN.RPN_POST_NMS_TOP_N = 2000\n# Proposal height and width both need to be greater than RPN_MIN_SIZE (at orig image scale)\n__C.TRAIN.RPN_MIN_SIZE = 16\n# Deprecated (outside weights)\n__C.TRAIN.RPN_BBOX_INSIDE_WEIGHTS = (1.0, 1.0, 1.0, 1.0)\n# Give the positive RPN examples weight of p * 1 / {num positives}\n# and give negatives a weight of (1 - p)\n# Set to -1.0 to use uniform example weighting\n__C.TRAIN.RPN_POSITIVE_WEIGHT = -1.0\n\n\n#\n# Testing options\n#\n\n__C.TEST = edict()\n\n# Scales to use during testing (can list multiple scales)\n# Each scale is the pixel size of an image's shortest side\n__C.TEST.SCALES = (600,)\n\n# Max pixel size of the longest side of a scaled input image\n__C.TEST.MAX_SIZE = 1000\n\n# Overlap threshold used for non-maximum suppression (suppress boxes with\n# IoU >= this threshold)\n__C.TEST.NMS = 0.3\n\n# Experimental: treat the (K+1) units in the cls_score layer as linear\n# predictors (trained, eg, with one-vs-rest SVMs).\n__C.TEST.SVM = False\n\n# Test using bounding-box regressors\n__C.TEST.BBOX_REG = True\n\n# Propose boxes\n__C.TEST.HAS_RPN = False\n\n# Test using these proposals\n__C.TEST.PROPOSAL_METHOD = 'selective_search'\n\n## NMS threshold used on RPN proposals\n__C.TEST.RPN_NMS_THRESH = 0.7\n## Number of top scoring boxes to keep before apply NMS to RPN proposals\n__C.TEST.RPN_PRE_NMS_TOP_N = 6000\n## Number of top scoring boxes to keep after applying NMS to RPN proposals\n__C.TEST.RPN_POST_NMS_TOP_N = 300\n# Proposal height and width both need to be greater than RPN_MIN_SIZE (at orig image scale)\n__C.TEST.RPN_MIN_SIZE = 16\n\n\n#\n# MISC\n#\n\n# The mapping from image coordinates to feature map coordinates might cause\n# some boxes that are distinct in image space to become identical in feature\n# coordinates. If DEDUP_BOXES > 0, then DEDUP_BOXES is used as the scale factor\n# for identifying duplicate boxes.\n# 1/16 is correct for {Alex,Caffe}Net, VGG_CNN_M_1024, and VGG16\n__C.DEDUP_BOXES = 1./16.\n\n# Pixel mean values (BGR order) as a (1, 1, 3) array\n# We use the same pixel mean for all networks even though it's not exactly what\n# they were trained with\n__C.PIXEL_MEANS = np.array([[[102.9801, 115.9465, 122.7717]]])\n\n# For reproducibility\n__C.RNG_SEED = 3\n\n# A small number that's used many times\n__C.EPS = 1e-14\n\n# Root directory of project\n__C.ROOT_DIR = osp.abspath(osp.join(osp.dirname(__file__), '..', '..'))\n\n# Data directory\n__C.DATA_DIR = osp.abspath(osp.join(__C.ROOT_DIR, 'data'))\n\n# Model directory\n__C.MODELS_DIR = osp.abspath(osp.join(__C.ROOT_DIR, 'models', 'pascal_voc'))\n\n# Name (or path to) the matlab executable\n__C.MATLAB = 'matlab'\n\n# Place outputs under an experiments directory\n__C.EXP_DIR = 'default'\n\n# Use GPU implementation of non-maximum suppression\n__C.USE_GPU_NMS = False\n\n# Default GPU device id\n__C.GPU_ID = 0\n\n\ndef get_output_dir(imdb, net=None):\n \"\"\"Return the directory where experimental artifacts are placed.\n If the directory does not exist, it is created.\n\n A canonical path is built using the name from an imdb and a network\n (if not None).\n \"\"\"\n outdir = osp.abspath(osp.join(__C.ROOT_DIR, 'output', __C.EXP_DIR, imdb.name))\n if net is not None:\n outdir = osp.join(outdir, net.name)\n if not os.path.exists(outdir):\n os.makedirs(outdir)\n return outdir\n\ndef _merge_a_into_b(a, b):\n \"\"\"Merge config dictionary a into config dictionary b, clobbering the\n options in b whenever they are also specified in a.\n \"\"\"\n if type(a) is not edict:\n return\n\n for k, v in a.iteritems():\n # a must specify keys that are in b\n if not b.has_key(k):\n raise KeyError('{} is not a valid config key'.format(k))\n\n # the types must match, too\n old_type = type(b[k])\n if old_type is not type(v):\n if isinstance(b[k], np.ndarray):\n v = np.array(v, dtype=b[k].dtype)\n else:\n raise ValueError(('Type mismatch ({} vs. {}) '\n 'for config key: {}').format(type(b[k]),\n type(v), k))\n\n # recursively merge dicts\n if type(v) is edict:\n try:\n _merge_a_into_b(a[k], b[k])\n except:\n print('Error under config key: {}'.format(k))\n raise\n else:\n b[k] = v\n\ndef cfg_from_file(filename):\n \"\"\"Load a config file and merge it into the default options.\"\"\"\n import yaml\n with open(filename, 'r') as f:\n yaml_cfg = edict(yaml.load(f))\n\n _merge_a_into_b(yaml_cfg, __C)\n\ndef cfg_from_list(cfg_list):\n \"\"\"Set config keys via list (e.g., from command line).\"\"\"\n from ast import literal_eval\n assert len(cfg_list) % 2 == 0\n for k, v in zip(cfg_list[0::2], cfg_list[1::2]):\n key_list = k.split('.')\n d = __C\n for subkey in key_list[:-1]:\n assert d.has_key(subkey)\n d = d[subkey]\n subkey = key_list[-1]\n assert d.has_key(subkey)\n try:\n value = literal_eval(v)\n except:\n # handle the case when v is a string literal\n value = v\n assert type(value) == type(d[subkey]), \\\n 'type {} does not match original type {}'.format(\n type(value), type(d[subkey]))\n d[subkey] = value\n</code></pre>\n\n<p>Whenever I run the code with a ZF net, I get the output images with the bounding box. </p>\n\n<p>The terminal output is given here for ZF : <a href=\"http://txt.do/5bqsf\" rel=\"nofollow\">http://txt.do/5bqsf</a></p>\n\n<p>However, when I run the code with the VGG_CNN_M_1024 net, there isn't any output images displayed, even though the code runs successfully. </p>\n\n<p>The terminal output is given here for VGG_CNN_M_1024 : <a href=\"http://txt.do/5bqsf\" rel=\"nofollow\">http://txt.do/5bqsf</a></p>\n\n<p>What do I change in the code ?</p>\n", "Lable": "D"} | |
| {"QuestionId": 37444951, "AnswerCount": 1, "Tags": "<tensorflow><deep-learning><deconvolution>", "CreationDate": "2016-05-25T18:25:02.090", "AcceptedAnswerId": "37446863", "Title": "How to stack multiple layers of conv2d_transpose() of Tensorflow", "Body": "<p>I'm trying to stack 2 layers of <code>tf.nn.conv2d_transpose()</code> to up-sample a tensor. It works fine during feed forward, but I get an error during backward propagation:\n<code>ValueError: Incompatible shapes for broadcasting: (8, 256, 256, 24) and (8, 100, 100, 24)</code>.</p>\n\n<p>Basically, I've just set the output of the first <code>conv2d_transpose</code> as the input of the second one:</p>\n\n<pre class=\"lang-py prettyprint-override\"><code>convt_1 = tf.nn.conv2d_transpose(...)\nconvt_2 = tf.nn.conv2d_transpose(conv_1)\n</code></pre>\n\n<p>Using just one <code>conv2d_transpose</code>, everything works fine. The error only occurs if multiple <code>conv2d_transpose</code> are stacked together.</p>\n\n<p>I'm not sure of the proper way of implementing multiple layer of <code>conv2d_transpose</code>. Any advice on how to go about this would be very much appreciated.</p>\n\n<p>Here's a small code that replicates the error:</p>\n\n<pre class=\"lang-py prettyprint-override\"><code>import numpy as np\nimport tensorflow as tf\n\nIMAGE_HEIGHT = 256\nIMAGE_WIDTH = 256\nCHANNELS = 1\n\nbatch_size = 8\nnum_labels = 2\n\nin_data = tf.placeholder(tf.float32, shape=(batch_size, IMAGE_HEIGHT, IMAGE_WIDTH, CHANNELS))\nlabels = tf.placeholder(tf.int32, shape=(batch_size, IMAGE_HEIGHT, IMAGE_WIDTH, 1))\n\n# Variables\nw0 = tf.Variable(tf.truncated_normal([3, 3, CHANNELS, 32]))\nb0 = tf.Variable(tf.zeros([32]))\n\n# Down sample\nconv_0 = tf.nn.relu(tf.nn.conv2d(in_data, w0, [1, 2, 2, 1], padding='SAME') + b0)\nprint(\"Convolution 0:\", conv_0)\n\n\n# Up sample 1. Upscale to 100 x 100 x 24\nwt1 = tf.Variable(tf.truncated_normal([3, 3, 24, 32]))\nconvt_1 = tf.nn.sigmoid(\n tf.nn.conv2d_transpose(conv_0, \n filter=wt1, \n output_shape=[batch_size, 100, 100, 24], \n strides=[1, 1, 1, 1]))\nprint(\"Deconvolution 1:\", convt_1)\n\n\n# Up sample 2. Upscale to 256 x 256 x 2\nwt2 = tf.Variable(tf.truncated_normal([3, 3, 2, 24]))\nconvt_2 = tf.nn.sigmoid(\n tf.nn.conv2d_transpose(convt_1, \n filter=wt2, \n output_shape=[batch_size, IMAGE_HEIGHT, IMAGE_WIDTH, 2], \n strides=[1, 1, 1, 1]))\nprint(\"Deconvolution 2:\", convt_2)\n\n# Loss computation\nlogits = tf.reshape(convt_2, [-1, num_labels])\nreshaped_labels = tf.reshape(labels, [-1])\ncross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(logits, reshaped_labels)\nloss = tf.reduce_mean(cross_entropy)\n\noptimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)\n</code></pre>\n", "Lable": "D"} | |
| {"QuestionId": 37539598, "AnswerCount": 1, "Tags": "<python><matrix><theano>", "CreationDate": "2016-05-31T07:35:27.590", "AcceptedAnswerId": null, "Title": "Error in converting TensorType(float32, matrix) to TensorType(int32, matrix)", "Body": "<p>I have written a code for a Deep Learning Algorithm. However I am stuck just in the final stage of loading the data.</p>\n\n<pre><code>self.x = T.imatrix(\"x\")\nself.y = T.ivector(\"y\")\n</code></pre>\n\n<p>are defined as the variables which hold the data</p>\n\n<p>then I do</p>\n\n<pre><code>train_x, train_y, train_lengths = dataUtils.read_and_sort_matlab_data(path+\"train.txt\",path+\"train_lbl.txt\")\nvalidate_x, validate_y, validate_lengths = dataUtils.read_and_sort_matlab_data(path+\"valid.txt\",path+\"valid_lbl.txt\")\ntested_x, tested_y, tested_lengths = dataUtils.read_and_sort_matlab_data(path+\"test.txt\",path+\"test_lbl.txt\")\n</code></pre>\n\n<p>Here I have checked the types of variables\ntrain_y is of type numpy.ndarray with shape(2000,)\nand train_y[0] is of type 'int32'.</p>\n\n<p>then I put the data into theano shared variables</p>\n\n<pre><code>training_x,training_y = shared(train_x,train_y)\nvalidation_x,validation_y = shared(validate_x,validate_y)\ntest_x,test_y = shared(tested_x,tested_y)\n</code></pre>\n\n<p>where the shared function is defined as follows</p>\n\n<pre><code>def shared(data_x,data_y):\n\n shared_x = theano.shared(np.asarray(data_x, dtype=theano.config.floatX), borrow=True)\n shared_y = theano.shared(np.asarray(data_y, dtype=theano.config.floatX), borrow=True)\n return shared_x, T.cast(shared_y, \"int32\")\n</code></pre>\n\n<p>I get the error in the following code</p>\n\n<pre><code>train_mb = theano.function(\n [i], cost, updates=updates,\n givens={\n self.x:\n training_x[i*self.document_length: (i+1)*self.document_length],\n self.y:\n training_y[i: (i+1)]\n })\n</code></pre>\n\n<p>At line </p>\n\n<pre><code>training_y[i: (i+1)]\n</code></pre>\n\n<p>And the error is</p>\n\n<p>TypeError: Cannot convert Type TensorType(float32, matrix) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(int32, matrix). You can try to manually convert Subtensor{int64:int64:}.0 into a TensorType(int32, matrix).</p>\n\n<p>Can someone tell where is the float32 being introduced when I have already cast the shared_y variable?? And how to correct this error. Also why are there matrices in the error statement when train_y is a vector as suggested ny its shape??</p>\n", "Lable": "D"} | |
| {"QuestionId": 37567147, "AnswerCount": 0, "Tags": "<javascript><jquery><html><css><css3>", "CreationDate": "2016-06-01T11:17:55.667", "AcceptedAnswerId": null, "Title": "On scroll, go to Y position and wait CSS animation to finish", "Body": "<p>Here is my problem. First, sorry for my bad english.</p>\n\n<p>I have resizing header on scroll <em>(100% windows height)</em>. And I have animation when it resizes and it's <em>0.5s long</em>. The problem is when I scroll more than once, animation doesn't finish and I have to go back.</p>\n\n<p>I need on scroll, to go on Y position, and wait animation to finish (disable scrolling) so i could see my content from beggining. And when animation finished than enable scrolling again.</p>\n\n<p>Here is my base script</p>\n\n<pre><code><script>\nfunction init() {\n window.addEventListener('scroll', function(e){\n var distanceY = window.pageYOffset || document.documentElement.scrollTop,\n shrinkOn = 50,\n header = document.querySelector(\"header\");\n if (distanceY > shrinkOn) {\n classie.add(header,\"smaller\");\n } else {\n if (classie.has(header,\"smaller\")) {\n classie.remove(header,\"smaller\");\n }\n }\n });\n}\nwindow.onload = init();\n</script>\n</code></pre>\n\n<p><strong>Here is my example link:</strong> <a href=\"http://codepen.io/anon/pen/dXPVJL\" rel=\"nofollow\">http://codepen.io/anon/pen/dXPVJL</a></p>\n", "Lable": "No"} | |
| {"QuestionId": 37581346, "AnswerCount": 4, "Tags": "<nlp><deep-learning><text-classification><keras>", "CreationDate": "2016-06-02T01:40:48.490", "AcceptedAnswerId": null, "Title": "How to deal with length variations for text classification using CNN (Keras)", "Body": "<p>It has been proved that CNN (convolutional neural network) is quite useful for text/document classification. I wonder how to deal with the length differences as the lengths of articles are different in most cases. Are there any examples in Keras? Thanks!! </p>\n", "Lable": "D"} | |
| {"QuestionId": 37610139, "AnswerCount": 0, "Tags": "<javascript><angularjs><angular-ui-router><bootstrap-table>", "CreationDate": "2016-06-03T09:00:29.687", "AcceptedAnswerId": null, "Title": "How to dynamically insert elements with AngularJS bindings into bootstrap table", "Body": "<p>I'm using the bootstrap table library and its AngularJS directive to create tables in my app. There I want to create a button inside a cell which triggers a table data dependent action. My code looks like this:</p>\n\n<p>TableController.js</p>\n\n<pre><code>(function () {\n 'use strict';\n\n angular\n .module('app.sitewithtable')\n .controller('TableController', TableController);\n\n TableController.$inject = ['TableDataService', 'logger', '$compile'];\n /* @ngInject */\n function TableController(TableDataService, logger, $compile) {\n var vm = this;\n vm.data= [];\n vm.getData = getData;\n vm.openModal = openModal;\n\n activate();\n\n function activate() {\n vm.data= getData();\n initTable();\n }\n\n function initTable() {\n vm.bsTableControl = {\n options: {\n data: vm.data,\n rowStyle: function (row, index) {\n return {classes: 'none'};\n },\n striped: true,\n columns: [{\n field: 'name',\n title: 'Name',\n align: 'center',\n valign: 'bottom'\n }, {\n field: 'startDate',\n title: 'Status',\n align: 'center',\n valign: 'middle',\n }, {\n field: 'status',\n title: '',\n align: 'center',\n valign: 'top',\n formatter: buttonFormatter\n }]\n }\n };\n }\n\n function getData() {\n return TableDataService.getData();\n }\n\n function buttonFormatter(val, row, index) {\n if (val == 0 && vm.data[index].missed === false) {\n return $compile('<button ng-click=\"vm.openModal\" class=\"btn btn-default\">Start</button>')(vm, function(elm, scope){\n return elm[0];\n });\n }\n return '';\n }\n function openModal(){\n console.log(\"imagine a modal window here\");\n }\n }\n})();\n</code></pre>\n\n<p>As far as I understand I must use <code>$compile</code> to make ng-* bindings work for dynamically inserted elements. In the browser I see <code>[object Object]</code> instead of the button. What is going wrong here?</p>\n", "Lable": "No"} | |
| {"QuestionId": 37610894, "AnswerCount": 2, "Tags": "<python><metaclass>", "CreationDate": "2016-06-03T09:38:12.310", "AcceptedAnswerId": "37611046", "Title": "__metaclass__ not worked when create class with type(\"Test\", (Base,), {'__metaclass__':Meta, ...})", "Body": "<pre><code>cls = type(\"Test\", (Base,), {\"__metaclass__\": Meta, \"a\": 1, ...})\n</code></pre>\n\n<p>I want to make some check for the attrs in the 3rd argument with Meta class, but this seem not worked, is there any other method?</p>\n", "Lable": "No"} | |
| {"QuestionId": 37661063, "AnswerCount": 2, "Tags": "<tensorflow>", "CreationDate": "2016-06-06T15:18:53.937", "AcceptedAnswerId": "37661461", "Title": "Variable initialization in the variable_scope in the Tensorflow", "Body": "<p>I've been trying to understand how variables are initialized in Tensorflow. Below, I created a simple example which defines a variable in some <code>variable_scope</code> and the process is wrapped in the subfunction.</p>\n\n<p>In my understanding, this code creates a variable <code>'x'</code> inside the <code>'test_scope'</code> at <code>tf.initialize_all_variables()</code> stage and it can always be accessed after that using <code>tf.get_variable()</code>. But this code ended up with the <code>Attempting to use uninitialized value</code> error at <code>print(x.eval())</code> line.</p>\n\n<p>I don't have any idea about how Tensorflow initializes variables. Can I get any help? Thank you.</p>\n\n<pre><code>import tensorflow as tf\n\ndef create_var_and_prod_with(y):\n with tf.variable_scope('test_scope'):\n x = tf.Variable(0.0, name='x', trainable=False)\n return x * y\n\ns = tf.InteractiveSession()\ny = tf.Variable(1.0, name='x', trainable=False)\ncreate_var_and_prod_with(y)\n\ns.run(tf.initialize_all_variables())\n\nwith tf.variable_scope('test_scope'):\n x = tf.get_variable('x', [1], initializer=tf.constant_initializer(0.0), trainable=False)\n print(x.eval())\n print(y.eval())\n</code></pre>\n", "Lable": "D"} | |
| {"QuestionId": 37714349, "AnswerCount": 1, "Tags": "<c#><json><json.net>", "CreationDate": "2016-06-08T23:03:24.713", "AcceptedAnswerId": "37714501", "Title": "JSON.net Deserialization with unique types", "Body": "<p>Before I start off - I should say I have very little experience with JSON. All of my experience with this has been with SnakeYaml in Java...</p>\n\n<p>Secondly, if you think it is better to pursue a secondary solution for this project, please let me know...</p>\n\n<p>I have a TCP server which accepts a json-formatted string and returns a json formatted string containing the requested information. Here's an example of what it'd be doing.</p>\n\n<p><strong>Request</strong></p>\n\n<pre><code>{\n 'MyName': 'John Doe'\n 'MandatoryLookup': false\n}\n</code></pre>\n\n<p><strong>Response</strong></p>\n\n<pre><code>{\n 'John Doe': {\n 'Location' : 'Big Office Building'\n 'Additional': 'Floor 2'\n }\n}\n</code></pre>\n\n<p>This part is working correctly and is provided only for understanding.</p>\n\n<p>Rerailing, the server that provides the response returns this information after completing a SQL query. What I would like it to do is to save this query within memory (using a custom object made below) as well as storing it in a json file on disk. When the server boots, I'd like it to read from this json file and deserialize it into my objects. This way, it can return a response almost right away instead of having to perform a lookup every time. In the case that the server does not have the information on hand or the \"MandatoryLookup\" flag is <code>true</code>, it queries the SQL server for the response.</p>\n\n<p>Here's the class for the custom object:</p>\n\n<pre><code>public class DataContainer\n{\n public string UserName { get; set; }\n public info LocationInfo locationInfo;\n}\n\npublic class LocationInfo\n{\n public string BuildingName { get; set; }\n public string AdditionalInfo { get; set; }\n}\n</code></pre>\n\n<p>^ The idea above goes to another StackOverflow thread I'd read regarding subcategories, though I don't know if this is correct provided the JSON string below.</p>\n\n<p><strong>RecentLookups.json</strong> ((This is the file saved to disk that I parse on startup))</p>\n\n<pre><code>{\n 'John Doe' : {\n 'Location' : 'Big Office Building',\n 'Additional' : 'Floor 2'\n },\n 'Jane Doe' : {\n 'Location' : 'Small Office Building',\n 'Additional' : 'Security Office'\n }\n}\n</code></pre>\n\n<p>This ultimately splits into three questions</p>\n\n<ol>\n<li>What would be the best place to start when looking at how to format my object for deserialization (because the way it is now doesn't work).</li>\n<li>Is worrying about pre-caching the formatted sql queries to disk worth the trouble (is the SQL lookup going to be fast enough to just have it look up the value every time)?</li>\n<li>How would I go about programmatically creating a uniquely named DataContainer object for each Json group? -- Example below</li>\n</ol>\n\n<p>The names of my JSON groups are not repeatable names -- that is, there will not be a group with a name like 'Jane Doe'. Instead, these examples were provided for readability. The real group names are unique identifiers for objects and the subcategories (location, additional) are information about said objects. What I would like is for each DataContainer object to have a unique name based off of the JSON category name, e.g. 'Jane Doe' would be <code>DataContainer JaneDoe</code> with the properties of that object set within.</p>\n\n<p>Sorry for the wall and thanks in advance.</p>\n", "Lable": "No"} | |
| {"QuestionId": 37720799, "AnswerCount": 2, "Tags": "<tensorflow>", "CreationDate": "2016-06-09T08:35:49.247", "AcceptedAnswerId": null, "Title": "How do you run Distributed Tensorflow on GKE?", "Body": "<p>I want to run the Distributed Tensorflow on GKE.\nYou want a sample of up to run of Distributed TensorFlow from the setting of GKE.\nDo you know a good sample?</p>\n", "Lable": "D"} | |
| {"QuestionId": 37736071, "AnswerCount": 1, "Tags": "<tensorflow><deep-learning>", "CreationDate": "2016-06-09T20:59:43.693", "AcceptedAnswerId": null, "Title": "Tensorflow out of memory", "Body": "<p>I am using tensorflow to build CNN based text classification. Some of the datasets are large and some are small.</p>\n\n<p>I use feed_dict to feed the network by sampling data from system memory (not GPU memory). The network is trained batch by batch. The batch size is 1024 fixed for every dataset.</p>\n\n<p>My question is:\nThe network is trained by batches, and each batch the code retrieve data from system memory. Therefore, no matter how large the dataset is the code should handle it like the same, right?</p>\n\n<p>But I got out of memory problem with large dataset, and for small dataset it works fine. I am pretty sure the system memory is enough for holding all the data. So the OOM problem is about tensorflow, right?</p>\n\n<p>Is it that I write my code wrong, or is it about tensorflow's memory management?</p>\n\n<p>Thanks a lot!</p>\n", "Lable": "D"} | |
| {"QuestionId": 37814389, "AnswerCount": 0, "Tags": "<python><theano><autoencoder>", "CreationDate": "2016-06-14T14:07:49.513", "AcceptedAnswerId": null, "Title": "Using a boolean variable in theano", "Body": "<p>I'm working on a bilingual autoencoder in theano. Taking <a href=\"http://deeplearning.net/tutorial/SdA.html\" rel=\"nofollow\">this tutorial</a> as reference, I created two monolingual autoencoders. Each takes a one-hot vector of a sentence and creates a latent representation which is a 100 dimensional numpy array. Then I concatenate these two (lat_1, lat_2) and here is where I'm having a problem. I want to mask one of the latent representations with 50% noise, so that one language needs to use the other latent representation as a clue to reconstruct itself. In theory this would alternate each epochs, so that both end up with optimum representations.</p>\n\n<p>At the moment, I think I've only managed it with one side. My idea was to add a self.corrupted variable at the beginning and set it to 0 and after each epoch, change the variable so that it would alternate. Here's the code I've added for this.</p>\n\n<pre><code>def get_corrupted_concat(self, lat_1, lat_2, corruption_level):\n if self.corrupted == 1:\n corr_lat_1 = self.get_corrupted_input(lat_1, corruption_level)\n concatenated = T.concatenate((corr_lat_1, lat_2), axis=1)\n self.corrupted = 0\n print('corrupting lat_1')\n else:\n corr_lat_2 = self.get_corrupted_input(lat_2, corruption_level)\n concatenated = T.concatenate((lat_1, corr_lat_2), axis=1)\n self.corrupted = 1\n print('corrupting lat_2')\n return concatenated\n</code></pre>\n\n<p>While training, however, it only prints 'corrupting lat_1' once at the beginning and continues training. Does anyone know a way to get this to alternate?</p>\n", "Lable": "D"} | |
| {"QuestionId": 37888097, "AnswerCount": 0, "Tags": "<conv-neural-network><keras>", "CreationDate": "2016-06-17T18:29:12.330", "AcceptedAnswerId": null, "Title": "How do I build a Fully Convolutional Neural Network in Keras?", "Body": "<p>I am working with Keras and when attempting to implement a FCNN with a similar architecture to VGG, I get the error:</p>\n\n<blockquote>\n <p>TypeError: img must be 4D tensor</p>\n</blockquote>\n\n<p>Here is my code for the FCNN:</p>\n\n<pre><code>def buildmodel():\n model = Sequential()\n model.add(Convolution2D(4,3,3,border_mode='same',input_shape=(3,64,64)))\n model.add(LeakyReLU(alpha=0.3))\n model.add(MaxPooling2D((2,2),strides=(2,2),border_mode='valid', dim_ordering='th'))\n model.add(Convolution2D(8,3,3,border_mode='same'))\n model.add(LeakyReLU(alpha=0.3))\n model.add(MaxPooling2D((2,2),strides=(2,2),border_mode='valid', dim_ordering='th'))\n\n model.add(UpSampling2D((2,2)))\n model.add(Convolution2D(16,3,3,border_mode='same',input_shape=x[0].shape))\n model.add(LeakyReLU(alpha=0.3))\n model.add(MaxPooling2D((2,2),strides=(2,2),border_mode='valid', dim_ordering='th'))\n model.add(Convolution2D(32,3,3,border_mode='same'))\n model.add(LeakyReLU(alpha=0.3))\n model.add(MaxPooling2D((2,2),strides=(2,2),border_mode='valid', dim_ordering='th'))\n\n model.add(UpSampling2D((2,2)))\n model.add(Convolution2D(64,3,3,border_mode='same',input_shape=x[0].shape))\n model.add(LeakyReLU(alpha=0.3))\n model.add(Convolution2D(64,3,3,border_mode='same'))\n model.add(LeakyReLU(alpha=0.3))\n model.add(MaxPooling2D((2,2),strides=(2,2),border_mode='valid', dim_ordering='th'))\n\n model.add(UpSampling2D((2,2)))\n model.add(Convolution2D(128,3,3,border_mode='same',input_shape=x[0].shape))\n model.add(LeakyReLU(alpha=0.3))\n model.add(Convolution2D(128,3,3,border_mode='same'))\n model.add(LeakyReLU(alpha=0.3))\n model.add(MaxPooling2D((2,2),strides=(2,2),border_mode='valid', dim_ordering='th'))\n\n model.add(UpSampling2D((2,2)))\n model.add(Convolution2D(4,3,3,border_mode='same',input_shape=x[0].shape))\n model.add(LeakyReLU(alpha=0.3))\n model.add(Convolution2D(1,3,3,border_mode='same',activation='sigmoid'))\n\n return model\n\ninputs = Input(shape=(len(x),3,64,64))\nfcnn = buildmodel()\noutputs = fcnn(inputs)\nprint(fcnn.inbound_nodes)\nopt = RMSprop(lr=0.001, rho=0.9, epsilon=1e-6) \nmodel = Model(input=inputs, output=outputs)\nmodel.compile(loss='hinge', optimizer=opt)\nmodel.fit(x)\n</code></pre>\n\n<p>x has a shape (nsamples,3,64,64). When using the VGG model verbatim in Keras with fully connected layers, there seemed to be no problem, so I'm confused as to how the new architecture is causing problems with the image shape. </p>\n", "Lable": "D"} | |
| {"QuestionId": 37897425, "AnswerCount": 1, "Tags": "<c#><.net><ssl><networking><server>", "CreationDate": "2016-06-18T13:20:00.047", "AcceptedAnswerId": "37905270", "Title": "AuthenticateAsServerAsync hangs", "Body": "<p>I'm using </p>\n\n<pre><code>await stream.AuthenticateAsServerAsync(serverCert, true, SslProtocols.Tls, false);\n</code></pre>\n\n<p>In my application to secure a connection.\nUnfortunately in rare cases (roughly one out of 1000) this hangs completely.\nI tried to set timeouts on the lower level <code>NetworkStream</code> and the <code>TcpClient</code>.</p>\n\n<p>But nothing works, those connections keep accumulating over time.</p>\n\n<p>And by it hangs completely I mean it gets stuck inside there for days (if the application runs that long).</p>\n\n<p>I currently solved this with a dirty hack. Im starting a new thread, wait 5seconds inside it, and if the call didnt return in time I call <code>tcpClient.Close()</code> to force the SslStream to abort.</p>\n\n<p>Whats the issue here?\nWhat is the intended way to handle scenarios like this in general where you need a timeout on a function but there is no overload that takes a TimeSpan or CancellationToken?</p>\n\n<p>Shouldnt the lower level timeouts on the tcpClient at least throw an exception? Why is that not happening either?</p>\n", "Lable": "No"} | |
| {"QuestionId": 37897934, "AnswerCount": 1, "Tags": "<tensorflow><word2vec><recurrent-neural-network><language-model>", "CreationDate": "2016-06-18T14:15:13.397", "AcceptedAnswerId": "37932988", "Title": "TensorFlow Embedding Lookup", "Body": "<p>I am trying to learn how to build RNN for Speech Recognition using TensorFlow. As a start, I wanted to try out some example models put up on TensorFlow page <a href=\"https://www.tensorflow.org/versions/master/tutorials/recurrent/index.html\" rel=\"noreferrer\">TF-RNN</a></p>\n\n<p>As per what was advised, I had taken some time to understand how word IDs are embedded into a dense representation (Vector Representation) by working through the basic version of word2vec model code. I had an understanding of what <code>tf.nn.embedding_lookup</code> actually does, until I actually encountered the same function being used with two dimensional array in <a href=\"https://www.tensorflow.org/versions/master/tutorials/recurrent/index.html\" rel=\"noreferrer\">TF-RNN</a> <code>ptb_word_lm.py</code>, when it did not make sense any more.</p>\n\n<h3>what I though <code>tf.nn.embedding_lookup</code> does:</h3>\n\n<p>Given a 2-d array <code>params</code>, and a 1-d array <code>ids</code>, function <code>tf.nn.embedding_lookup</code> fetches rows from params, corresponding to the indices given in <code>ids</code>, which holds with the dimension of output it is returning.</p>\n\n<h3>What I am confused about:</h3>\n\n<p>When tried with same params, and 2-d array <code>ids</code>, <code>tf.nn.embedding_lookup</code> returns 3-d array, instead of 2-d which I do not understand why.</p>\n\n<p>I looked up the manual for <a href=\"https://www.tensorflow.org/versions/r0.9/api_docs/python/nn.html#embedding_lookup\" rel=\"noreferrer\">Embedding Lookup</a>, but I still find it difficult to understand how the partitioning works, and the result that is returned. I recently tried some simple example with <code>tf.nn.embedding_lookup</code> and it appears that it returns different values each time. Is this behaviour due to the randomness involved in partitioning ?</p>\n\n<p>Please help me understand how <code>tf.nn.embedding_lookup</code> works, and why is used in both <code>word2vec_basic.py</code>, and <code>ptb_word_lm.py</code> i.e., what is the purpose of even using them ?</p>\n", "Lable": "D"} | |
| {"QuestionId": 37904614, "AnswerCount": 1, "Tags": "<tensorflow><conv-neural-network>", "CreationDate": "2016-06-19T06:39:07.410", "AcceptedAnswerId": "38267767", "Title": "Implementing hypercolumn in neural nets with tensorflow", "Body": "<p>I was trying to add <a href=\"https://people.eecs.berkeley.edu/~rbg/papers/cvpr15/hypercolumn.pdf\" rel=\"nofollow\">hypercolumns</a> idea to my neural net model. How can I do this using tensorflow?</p>\n", "Lable": "D"} | |
| {"QuestionId": 37968613, "AnswerCount": 0, "Tags": "<c++><windows><visual-studio-2013>", "CreationDate": "2016-06-22T12:52:10.863", "AcceptedAnswerId": null, "Title": "Visual Studio doesn't recognize Windows' data types even including its header", "Body": "<p>I'm writing a Timer class in VS2013 using some Windows features but Visual Studio doesn't recognize them even including windows.h header.</p>\n\n<p>Win32Timer.h</p>\n\n<pre><code>#pragma once\n\n#include \"Timer.h\"\n\n #ifndef WIN32_LEAN_AND_MEAN\n # define WIN32_LEAN_AND_MEAN\n #endif\n #if !defined(NOMINMAX) && defined(_MSC_VER)\n # define NOMINMAX\n #endif\n #include <windows.h>\n\n class Win32Timer : public Timer {\n public:\n Win32Timer();\n ~Win32Timer();\n\n void reset() override;\n ulong getMilliseconds() override;\n ulong getMillisecondsCPU() override;\n ulong getMicroseconds() override;\n ulong getMicrosecondsCPU() override;\n\n protected:\n ulong getTime() override;\n\n private:\n clock_t m_StartClock;\n\n DWORD m_StartTick;\n LONGLONG m_LastTime;\n LARGE_INTEGER m_StartTime;\n LARGE_INTEGER m_Frequency;\n\n };\n</code></pre>\n\n<p>Timer.h (Prerequisites.h is just a bunch of forward declarations and STL headers)</p>\n\n<pre><code>#pragma once\n\n#include \"Prerequisites.h\"\n\nclass Timer {\n public:\n Timer();\n ~Timer();\n\n virtual void reset() = 0;\n virtual ulong getMilliseconds() = 0;\n virtual ulong getMillisecondsCPU() = 0;\n virtual ulong getMicroseconds() = 0;\n virtual ulong getMicrosecondsCPU() = 0;\n\n protected:\n virtual ulong getTime();\n};\n</code></pre>\n\n<p>When I try to compile I get the following errors for each member variable that uses the windows' data types.</p>\n\n<blockquote>\n <p>1>c:\\users\\jean\\documents\\visual studio 2013\\projects\\drac\\drac\\win32timer.h(33): error C2146: syntax error : missing ';' before identifier 'm_LastTime'</p>\n \n <p>1>c:\\users\\jean\\documents\\visual studio 2013\\projects\\drac\\drac\\win32timer.h(33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int</p>\n</blockquote>\n\n<p>If I click to go to definition, VS takes me to the right place where the data type is defined but fails to recognize it in compile time. What could the problem be?</p>\n\n<p>If I include <code><winnt.h></code> instead of <code><windows.h></code> the types are recognized but I get a <code>fatal error C1189: #error : \"No Target Architecture\"</code>.</p>\n", "Lable": "No"} | |