{"QuestionId": 38155065, "AnswerCount": 5, "Tags": " In the first table I have orders. In the second - messages which send to these orders. I need to get date and status from the last message (or NULL if messages didn`t send yet) for each orders where has active=1. The tables connected by composite key - \"order_id + offer\". \"orders\" table: \"sms\" table: The result will be: This query works not correctly: It show: For key \"6 kopiya-3\" it return status=0 but expected 1, because it get this value from the first row instead row with max date. How can I fix this? How to get name of the branch I'm merging from? git status tells me only that I'm merging, but I forgot what branch exactly I'm merging... I have been working on Udacity's course on deep learning- which I must add is great! I am very happy with the assignments so far. But there are two lines of code, that I am not quite understanding. I have put asterisks around the parts of the code that I do not quite understand. First, I am not quite sure why the first set of biases between the input and convolutional layer are zeros, and then in the second layer they are then all ones. Next, I do not understand the following line of code: Specifically, I don't get why we have used If you need more information then please let me know. This is taken from Udacity's deep learning course, where the notebooks are able to be cloned from GitHub. Many thanks :) I have a hdf5 training dataset with size I want to ask: How to feed I have a test.csv file that is formatted as: I have a hashmap that reads a file that contains the same header contents such as the CSV, just a different format, with no accompanying data. In example: where, Key, Value I have also created a second hash map that: I want to read and compare the hashmap, if the container map has a value that is in the value map, then I put that value in to a corresponding object. example object I want to create a function where the data is set inside the object when the hashmaps are compared and when a value map key is equal to a contain map key, and the value is placed is set into the object. Something really simply that is efficient at handling the setting as well. Please note: I made the CSV header and the rows finite, in real life, the CSV could have x number of fields(Home,Owner,Lat,Long,houseType,houseColor, ect..), and a n number of values associated to those fields I'm trying to use raspberry pi camera to capture image and classify the image in real time into three classes. What I did is using the code below. It can predict in the first iteration. The problem is that it shows me ran out of memory after the second iteration. Is there anyway to fix this? A professor of mine gave me a small script that he uses to visualize the evolution of his neural net after every epoch of learning. This is a plot of 3 values: train loss, train error and test error. What is the difference between the first two? WPF provides some amazing features to work with animations. I was wondering if it would be fit for the development of simple games like Istrolid. I believe WPF can replicate almost (if not all) of the animation in Istrolid. I am good with WPF, but I am yet to start with Unity. Is WPF better in my case or is it worth investing time in learning Unity for the development of such simple games. Some of my users are students. When a user creates a student profile the StudentProfile class is instantiated: How can I check if a user is a student? returns False even when the logged-in user has an associated StudentProfile. i'm trying to change UIColloectionViewCustomLayout scrollDicretion to Horizontal. I have tried to : I need get this results Now i have this In my application I have a scrolling menu and I use this function to full menu items. But most of the time I am getting out of memory error. I don't get error in my emulator. But my device fails all the time.\nI tried and reduced the images size too. But device says that it takes too much of memory. I want my app to be faster loading and memory efficient. I am still a starter in android. I saw some articles about loading images efficiently. But I didn't understand. Can anyone help me with some sample code? I have a hamburger nav that does not stay fixed on the page. I know many said that if you set the
\n\n+----------+----------+--------+----------+\n| order_id | offer | active | timezone |\n+----------+----------+--------+----------+\n| 6 | kopiya | 1 | 0 |\n| 6 | kopiya-3 | 1 | 0 |\n| 10 | kopiya | 1 | 180 |\n| 23 | kopiya-2 | 1 | 0 |\n| 27 | kopiya-2 | 0 | 0 |\n+----------+----------+--------+----------+\n
\n\n+------+----------+----------+------+--------+---------------------+\n| key_ | order_id | offer | type | status | date |\n+------+----------+----------+------+--------+---------------------+\n| 1 | 6 | kopiya | text | 1 | 2016-06-20 00:00:00 |\n| 2 | 6 | kopiya-3 | text | 0 | 2016-06-21 00:00:00 |\n| 3 | 10 | kopiya | text | 0 | 2016-06-27 00:00:00 |\n| 4 | 27 | kopiya-2 | text | 1 | 2016-06-21 00:00:00 |\n| 6 | 6 | kopiya-3 | text | 1 | 2016-06-23 00:00:00 |\n+------+----------+----------+------+--------+---------------------+\n
\n\n+----------+----------+---------------------+--------+\n| order_id | offer | last_date | status |\n+----------+----------+---------------------+--------+\n| 6 | kopiya | 2016-06-20 00:00:00 | 1 |\n| 6 | kopiya-3 | 2016-06-23 00:00:00 | 1 |\n| 10 | kopiya | 2016-06-27 00:00:00 | 0 |\n| 23 | kopiya-2 | NULL | NULL |\n+----------+----------+---------------------+--------+\n
\n\nSELECT o.order_id, o.offer, max(date) as last_date, status\nFROM orders AS o\nLEFT JOIN sms AS s\nON o.order_id=s.order_id AND o.offer=s.offer\nWHERE `active` = 1\nGROUP BY o.order_id, o.offer;\n
\n\n+----------+----------+---------------------+--------+\n| order_id | offer | last_date | status |\n+----------+----------+---------------------+--------+\n| 6 | kopiya | 2016-06-20 00:00:00 | 1 |\n| 6 | kopiya-3 | 2016-06-23 00:00:00 | 0 |\n| 10 | kopiya | 2016-06-27 00:00:00 | 0 |\n| 23 | kopiya-2 | NULL | NULL |\n+----------+----------+---------------------+--------+\n
\n", "Lable": "No"}
{"QuestionId": 38211862, "AnswerCount": 1, "Tags": "On branch master\nYour branch is up-to-date with 'origin/master'.\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n
\n\nbatch_size = 20\npatch_size = 5\ndepth = 16\nnum_hidden = 64\n\ngraph = tf.Graph()\n\nwith graph.as_default():\n\n # Input data.\n tf_train_dataset = tf.placeholder(\n tf.float32, shape=(batch_size, image_size, image_size, num_channels))\n tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels))\n tf_valid_dataset = tf.constant(valid_dataset)\n tf_test_dataset = tf.constant(test_dataset)\n\n # Variables.\n layer1_weights = tf.Variable(tf.truncated_normal(\n [patch_size, patch_size, num_channels, depth], stddev=0.1))\n layer1_biases = tf.Variable(tf.zeros([depth]))\n layer2_weights = tf.Variable(tf.truncated_normal(\n [patch_size, patch_size, depth, depth], stddev=0.1))\n ***********************************************************\n layer2_biases = tf.Variable(tf.constant(1.0, shape=[depth]))\n ***********************************************************\n layer3_weights = tf.Variable(tf.truncated_normal(\n [image_size // 4 * image_size // 4 * depth, num_hidden], stddev=0.1))\n ***********************************************************\n layer3_biases = tf.Variable(tf.constant(1.0, shape=[num_hidden]))\n layer4_weights = tf.Variable(tf.truncated_normal(\n [num_hidden, num_labels], stddev=0.1))\n layer4_biases = tf.Variable(tf.constant(1.0, shape=[num_labels]))\n\n # Model.\n def model(data):\n conv = tf.nn.conv2d(data, layer1_weights, [1, 2, 2, 1], padding='SAME')\n hidden = tf.nn.relu(conv + layer1_biases)\n conv = tf.nn.conv2d(hidden, layer2_weights, [1, 2, 2, 1], padding='SAME')\n hidden = tf.nn.relu(conv + layer2_biases)\n shape = hidden.get_shape().as_list()\n reshape = tf.reshape(hidden, [shape[0], shape[1] * shape[2] * shape[3]])\n hidden = tf.nn.relu(tf.matmul(reshape, layer3_weights) + layer3_biases)\n return tf.matmul(hidden, layer4_weights) + layer4_biases\n\n # Training computation.\n logits = model(tf_train_dataset)\n loss = tf.reduce_mean(\n tf.nn.softmax_cross_entropy_with_logits(logits, tf_train_labels))\n\n # Optimizer.\n optimizer = tf.train.GradientDescentOptimizer(0.05).minimize(loss)\n\n # Predictions for the training, validation, and test data.\n train_prediction = tf.nn.softmax(logits)\n valid_prediction = tf.nn.softmax(model(tf_valid_dataset))\n test_prediction = tf.nn.softmax(model(tf_test_dataset))\n
\n\nlayer3_weights = tf.Variable(tf.truncated_normal(\n [image_size // 4 * image_size // 4 * depth, num_hidden], stddev=0.1))\nimage_size // 4 * image_size // 4 * depth, and I especially don't understand why we have used 4.(21760, 1, 33, 33). 21760 is the whole number of training samples. I want to use the mini-batch training data with the size 128 to train the network. 128 mini-batch training data from the whole dataset with tensorflow each time?
\n\nHome,Owner,Lat,Long\n5th Street,John,5.6765,-6.56464564\n7th Street,Bob,7.75,-4.4534564\n9th Street,Kyle,4.64,-9.566467364\n10th Street,Jim,14.234,-2.5667564\n
\n\nMap<Integer, String> container = new HashMap<>();\n
\n\n[0][NULL]\n[1][Owner]\n[2][Lat]\n[3][NULL]\n
\n\nBufferedReader reader = new BufferedReader (new FileReader(\"test.csv\"));\nCSVParser parser = new CSVParser(reader, CSVFormat.DEFAULT);\nBoolean headerParsed = false;\nCSVRecord headerRecord = null;\nint i;\nMap<String,String> value = new HashMap<>();\nfor (final CSVRecord record : parser) {\n if (!headerParsed = false) {\n headerRecord = record;\n headerParsed = true;\n }\n for (i =0; i< record.size(); i++) {\n value.put (headerRecord.get(0), record.get(0));\n }\n}\n
\n\npublic DataSet (//args) {\n this.home\n this.owner\n this.lat\n this.longitude\n}\n
\n", "Lable": "D"}
{"QuestionId": 38303348, "AnswerCount": 2, "Tags": "import numpy as np\nimport tensorflow as tf\nimport argparse\nimport os\nimport sys\n\ndef create_graph(model_file):\n \"\"\"Creates a graph from saved GraphDef file and returns a saver.\"\"\"\n # Creates graph from saved graph_def.pb.\n with tf.gfile.FastGFile(model_file, 'rb') as f:\n graph_def = tf.GraphDef()\n graph_def.ParseFromString(f.read())\n _ = tf.import_graph_def(graph_def, name='')\n\n\ndef run_inference(images, out_file, labels, model_file, k=5):\n\n # Creates graph from saved GraphDef.\n create_graph(model_file)\n\n if out_file:\n out_file = open(out_file, 'wb', 1)\n\n with tf.Session() as sess:\n softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')\n for img in images:\n if not tf.gfile.Exists(img):\n tf.logging.fatal('File does not exist %s', img)\n continue\n image_data = tf.gfile.FastGFile(img, 'rb').read()\n\n\n predictions = sess.run(softmax_tensor,\n {'DecodeJpeg/contents:0': image_data})\n predictions = np.squeeze(predictions)\n top_k = predictions.argsort()[-k:][::-1] # Getting top k predictions\n\n vals = []\n for node_id in top_k:\n human_string = labels[node_id]\n score = predictions[node_id]\n vals.append('%s=%.5f' % (human_string, score))\n rec = \"%s\\t %s\" % (img, \", \".join(vals))\n if out_file:\n out_file.write(rec)\n out_file.write(\"\\n\")\n else:\n print(rec) \n if out_file:\n print(\"Output stored to a file\")\n out_file.close()\n\nif __name__ == '__main__':\n parser = argparse.ArgumentParser(description='Classify Image(s)')\n parser.add_argument('-i','--in', help='Input Image file ')\n parser.add_argument('-li','--list', help='List File having input image paths')\n parser.add_argument('-o','--out', help='Output file for storing the content')\n parser.add_argument('-m','--model', help='model file path (protobuf)', required=True)\n parser.add_argument('-l','--labels', help='labels text file', required=True)\n parser.add_argument('-r','--root', help='path to root directory of input data')\n args = vars(parser.parse_args())\n # Read input\n if not args['in'] and not args['list']:\n print(\"Either -in or -list option is required.\")\n sys.exit(1)\n if args['in']:\n images = [args['in']]\n else: # list must be given\n with open(args['list']) as ff:\n images = filter(lambda x: x, map(lambda y: y.strip(), ff.readlines()))\n\n # if a separate root directory given then make a new path\n if args['root']:\n print(\"Input data from : %s\" % args['root'])\n images = map(lambda p: os.path.join(args['root'], p), images)\n\n with open(args['labels'], 'rb') as f:\n labels = [str(w).replace(\"\\n\", \"\") for w in f.readlines()]\n\n while True:\n imagename='/home/pi/Desktop/camerasnap.jpg'\n images=raspi.capture(imagename)\n run_inference(images=images, out_file=args['out'], labels=labels, model_file=args['model'])\n
\n\nclass StudentProfile(models.Model):\n user = models.OneToOneField(settings.AUTH_USER_MODEL, primary_key=True)\n \u2026\n
\n\nhasattr(request.user, 'StudentProfile')\n
\n\nlet layout = CollectionViewLayout()\n layout.scrollDirection = .Horizontal\n self.collectionView.collectionViewLayout = layout\n
\n\n[1][4][7]\n[2][5][8]\n[3][6][9]\n
\n", "Lable": "No"}
{"QuestionId": 38416785, "AnswerCount": 1, "Tags": "[1][2][3]\n[4][5][6]\n[7][6][9]\n
\n\n android:hardwareAccelerated=\"false\"\n android:largeHeap=\"true\"\n
\n", "Lable": "No"}
{"QuestionId": 38448868, "AnswerCount": 1, "Tags": "public void RefreshMenuItems(int category) {\n //Create menu scroller\n LinearLayout.LayoutParams card_lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);\n card_lp.setMargins(dp(5), 0, dp(5), 0);\n\n LinearLayout.LayoutParams image_lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, 0);\n image_lp.setMargins(dp(40), dp(5), dp(40), dp(5));\n image_lp.weight = 0.5f;\n\n LinearLayout.LayoutParams desc_lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0);\n desc_lp.weight = 0.32f;\n\n LinearLayout.LayoutParams title_lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0);\n title_lp.weight = 0.08f;\n\n RelativeLayout.LayoutParams price_rp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);\n price_rp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);\n\n RelativeLayout.LayoutParams buy_rp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);\n buy_rp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);\n\n LinearLayout.LayoutParams bottom_lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0);\n bottom_lp.weight = 0.1f;\n\n //fill menu\n for (int i = 0; i < item_title.length; i++) {\n final int currenti = i;\n\n if ((item_category[i] == category) || category == 0) {\n TextView title = new TextView(this);\n title.setText(item_title[currenti]);\n title.setGravity(Gravity.CENTER);\n title.setTextColor(0xff212121);\n title.setPadding(dp(10), dp(0), dp(10), dp(0));\n title.setTypeface(null, Typeface.BOLD);\n title.setLayoutParams(title_lp);\n title.setBackgroundResource(R.drawable.borderradius2);\n title.setTextSize(fontpercent_screenheight(2.5));\n\n ImageView item = new ImageView(this);\n item.setImageResource(getResources().getIdentifier(item_image[i], \"drawable\", getPackageName()));\n item.setScaleType(ScaleType.FIT_CENTER);\n item.setAdjustViewBounds(true);\n item.setLayoutParams(image_lp);\n\n TextView desc = new TextView(this);\n desc.setText(item_shortdesc[currenti]);\n desc.setPadding(dp(10), dp(5), dp(10), dp(5));\n desc.setLayoutParams(desc_lp);\n desc.setTextSize(fontpercent_screenheight(2.5));\n\n TextView price = new TextView(this);\n price.setText(String.format(sign + \"%.2f\", Double.parseDouble(item_price[currenti])));\n price.setPadding(0, dp(5), dp(10), dp(5));\n price.setLayoutParams(price_rp);\n price.setTextSize(fontpercent_screenheight(2.5));\n\n buy = new TextView(this);\n buy.setText(R.string.MenuAddToOrderButton);\n buy.setPadding(dp(10), dp(5), 0, dp(5));\n buy.setTextColor(0xffff0000);\n buy.setLayoutParams(buy_rp);\n buy.setTextSize(fontpercent_screenheight(2.5));\n buy.setClickable(true);\n buy.setOnClickListener(new OnClickListener() {\n @Override\n public void onClick(View v) {\n addItemToOrder(currenti);\n }\n });\n buy.setOnTouchListener(new OnTouchListener() {\n @Override\n public boolean onTouch(View v, MotionEvent event) {\n if (event.getAction() == MotionEvent.ACTION_DOWN) {\n ((TextView) v).setTextColor(0xff212121);\n } else if (event.getAction() == MotionEvent.ACTION_UP) {\n ((TextView) v).setTextColor(0xffff0000);\n }\n return false;\n }\n });\n\n RelativeLayout bottom = new RelativeLayout(this);\n bottom.setLayoutParams(bottom_lp);\n bottom.addView(buy);\n bottom.addView(price);\n\n LinearLayout card = new LinearLayout(this);\n card.setOrientation(LinearLayout.VERTICAL);\n card.setLayoutParams(card_lp);\n card.setBackgroundResource(R.drawable.borderradius1);\n card.setWeightSum(1f);\n card.setOnClickListener(new OnClickListener() {\n @Override\n public void onClick(View v) {\n Intent intent = new Intent(context, ItemProfile.class).putExtra(\"item_image\", getResources().getIdentifier(item_image[currenti], \"drawable\", getPackageName())).putExtra(\"item_title\", item_title[currenti]).putExtra(\"item_desc\", item_desc[currenti]).putExtra(\"item_price\", Double.parseDouble(item_price[currenti]));\n startActivity(intent);\n }\n });\n\n card.addView(title);\n card.addView(item);\n card.addView(desc);\n card.addView(bottom);\n\n menu.addView(card);\n }\n }\n}\nposition:fixed should work. But I am still having issues. Here are some snippets. And you can also find the the code here - Codepen.
\r\n$('.menu-burger, .menu-items').on('click', function() {\r\n $('.menu-bg, .menu-items, .menu-burger').toggleClass('fs');\r\n $('.menu-burger').text() == \"\u2630\" ? $('.menu-burger').text('\u2715') : $('.menu-burger').text('\u2630');\r\n});
\r\n.menu,\r\n.menu-bg,\r\n.menu-burger {\r\n position: fixed;\r\n width: 50px;\r\n height: 50px;\r\n font-size: 30px;\r\n text-align: center;\r\n border-radius: 100%;\r\n right: 25px;\r\n top: 25px;\r\n border-width: 0 0 1px;\r\n}\r\n.menu-bg {\r\n position: fixed;\r\n background: #f91791;\r\n pointer-events: none;\r\n transition: .3s;\r\n right: 50px;\r\n top: 50px;\r\n transform: translate3d(50%, -50%, 0);\r\n transform-origin: center center;\r\n}\r\n.menu-bg.fs {\r\n transform: translate3d(50%, -50%, 0);\r\n width: 2000vw;\r\n height: 2000vw;\r\n}\r\n.menu-burger {\r\n position: fixed;\r\n color: #fff;\r\n padding-top: 11px;\r\n -webkit-user-select: none;\r\n cursor: pointer;\r\n transition: .4s;\r\n transform-origin: center;\r\n}\r\n.menu-burger.fs {\r\n transform: rotate(-180deg) translateY(10px);\r\n}\r\n.menu-items {\r\n font-family: 'Abril Fatface', serif;\r\n font-size: 125px;\r\n line-height: 120px;\r\n position: absolute;\r\n color: #fff;\r\n width: 100%;\r\n text-align: left;\r\n opacity: 0;\r\n transition: .4s;\r\n margin-top: 25px;\r\n transform: translateY(-200%);\r\n pointer-events: none;\r\n -webkit-font-smoothing: antialiased;\r\n}\r\n.menu-items div {\r\n color: #fff;\r\n transition: 1s;\r\n opacity: 0;\r\n margin-top: 0px;\r\n}\r\n.menu-items div a {\r\n color: #fff;\r\n text-decoration: none;\r\n}\r\n.menu-items.fs {\r\n transform: translateY(0);\r\n pointer-events: auto;\r\n opacity: 1;\r\n}\r\n.menu-items.fs div {\r\n color: #fff;\r\n opacity: 1;\r\n}\r\n.menu-items.fs div a {\r\n color: #fff;\r\n text-decoration: none;\r\n}\r\n.menu-items.fs div a:hover {\r\n color: #000;\r\n text-decoration: none;\r\n transition: .4s;\r\n}
\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>\r\n<header class=\"close\">\r\n <nav class=\"nav\">\r\n <div class=\"container\">\r\n <div class=\"menu-bg\"></div>\r\n <div class=\"menu-burger\">\u2630</div>\r\n <div class=\"menu-items\">\r\n <div><a href=\"#welcome\">Home</a></div>\r\n <div><a href=\"#about\">About Me</a></div>\r\n <div><a href=\"#portfolio\">Skills</a></div>\r\n <div><a href=\"#resume\">Portfolio</a></div>\r\n <div><a href=\"#contactMe\">Contact Me</a></div>\r\n </div>\r\n </div>\r\n </nav>\r\n</header>
I'm really new with tensorflow and I'm sure that I'm doing something wrong here. My problem is that when I'm reading records from file, code works some times, but most of the time it fails:
\n\n\n\nimport tensorflow as tf\nimport numpy as np\nimport time\n\ndef readFrame(inQueue, reader):\n frameWidth = int(1920/16)+1\n frameHeight = int(1080/16)+1\n frameItemsCount = frameWidth*frameHeight\n\n _, serialized_frame = reader.read(inQueue)\n features = tf.parse_single_example(\n serialized_frame,\n features= {\n 'x' : tf.FixedLenFeature([frameItemsCount], tf.float32)\n , 'y' : tf.FixedLenFeature([frameItemsCount], tf.float32)\n , 'direction': tf.FixedLenFeature([frameItemsCount], tf.float32)\n # , 'force' : tf.FixedLenFeature([frameItemsCount], tf.float32)\n # , 'sad' : tf.FixedLenFeature([frameItemsCount], tf.float32)\n })\n\n return features\n\n# pretty much copy paste from fully_connected_reader.py\ndef main(_):\n with tf.Graph().as_default():\n inputFramesQueue = tf.train.string_input_producer([\"tfrecords.out\"], num_epochs=100)\n reader = tf.TFRecordReader()\n\n init_op = tf.initialize_all_variables()\n sess = tf.Session()\n sess.run(init_op)\n coord = tf.train.Coordinator()\n threads = tf.train.start_queue_runners(sess=sess, coord=coord)\n\n try:\n step = 0\n while not coord.should_stop() and step < 3:\n start_time = time.time()\n frameDict = readFrame(inputFramesQueue, reader)\n print(frameDict)\n frame = sess.run([\n frameDict['x']\n , frameDict['y']\n , frameDict['direction'] \n # , frameDict['force'] \n # , frameDict['sad']\n ])\n print(frame[2])\n\n duration = time.time() - start_time\n if step % 100 == 0: print('Step %d: (%.3f sec)' % (step, duration))\n step += 1\n except tf.errors.OutOfRangeError:\n print('Done training for %d epochs, %d steps.' % (FLAGS.num_epochs, step))\n finally:\n coord.request_stop()\n\n coord.join(threads)\n sess.close()\n\nif __name__ == '__main__':\n tf.app.run()\n\n\nFor example when I run it these are two different outputs I'm getting:
\n\n(venv) bash-3.2$ python src/readframes.py\n{'x': <tf.Tensor 'ParseSingleExample/Squeeze_x:0' shape=(8228,) dtype=float32>, 'direction': <tf.Tensor 'ParseSingleExample/Squeeze_direction:0' shape=(\n8228,) dtype=float32>, 'y': <tf.Tensor 'ParseSingleExample/Squeeze_y:0' shape=(8228,) dtype=float32>}\nTraceback (most recent call last):\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/client/session.py\", line 715, in _do_call\n return fn(*args)\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/client/session.py\", line 697, in _run_fn\n status, run_metadata)\n File \"/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py\", line 66, in __exit__\n next(self.gen)\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/framework/errors.py\", line 450, in raise_ex\nception_on_not_ok_status\n pywrap_tensorflow.TF_GetCode(status))\ntensorflow.python.framework.errors.NotFoundError: FetchOutputs node ParseSingleExample/Squeeze_y:0: not found\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"src/readframes.py\", line 62, in <module>\n tf.app.run()\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/platform/app.py\", line 30, in run\n sys.exit(main(sys.argv))\n File \"src/readframes.py\", line 44, in main\n , frameDict['direction']\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/client/session.py\", line 372, in run\n run_metadata_ptr)\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/client/session.py\", line 636, in _run\n feed_dict_string, options, run_metadata)\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/client/session.py\", line 708, in _do_run\n target_list, options, run_metadata)\n File \"/Users/mikaelle/Projects/Omat/tensorflow-grouping/venv/lib/python3.5/site-packages/tensorflow/python/client/session.py\", line 728, in _do_call\n raise type(e)(node_def, op, message)\ntensorflow.python.framework.errors.NotFoundError: FetchOutputs node ParseSingleExample/Squeeze_y:0: not found\n(venv) bash-3.2$\n\n(venv) bash-3.2$ python src/readframes.py\n{'y': <tf.Tensor 'ParseSingleExample/Squeeze_y:0' shape=(8228,) dtype=float32>, 'direction': <tf.Tensor 'ParseSingleExample/Squeeze_direction:0' shape=(\n8228,) dtype=float32>, 'x': <tf.Tensor 'ParseSingleExample/Squeeze_x:0' shape=(8228,) dtype=float32>}\n[ 0. 0. 0. ..., 0. 0. 0.]\nStep 0: (0.014 sec)\n{'y': <tf.Tensor 'ParseSingleExample_1/Squeeze_y:0' shape=(8228,) dtype=float32>, 'direction': <tf.Tensor 'ParseSingleExample_1/Squeeze_direction:0' sha\npe=(8228,) dtype=float32>, 'x': <tf.Tensor 'ParseSingleExample_1/Squeeze_x:0' shape=(8228,) dtype=float32>}\n[ 0. 0. 0. ..., 0. 0. 0.]\n{'y': <tf.Tensor 'ParseSingleExample_2/Squeeze_y:0' shape=(8228,) dtype=float32>, 'direction': <tf.Tensor 'ParseSingleExample_2/Squeeze_direction:0' sha\npe=(8228,) dtype=float32>, 'x': <tf.Tensor 'ParseSingleExample_2/Squeeze_x:0' shape=(8228,) dtype=float32>}\n[ 0. 2.24240255 2.24240255 ..., 0. 0. 0. ]\n(venv) bash-3.2$\n\n\nSomehow it seems that file cannot be accessed when items are tried to be fetched from there...
\n", "Lable": "D"} {"QuestionId": 38483157, "AnswerCount": 2, "Tags": "I would like to automate an existing process that involves executing programs on a Linux server which would then send output file(s) to be edited by excel. The resulting .csv files must be run on a Windows DOS command prompt. If I would like to automate this process, one of the things that I would like to know is if it's possible for me to write and run a script on a Linux server to call a Windows DOS command prompt. Any suggestions?
\n", "Lable": "No"} {"QuestionId": 38500570, "AnswerCount": 2, "Tags": "I'm trying to use a validation monitor in skflow by passing my validation set as numpy array.
\n\nHere is some simple code to reproduce the problem (I installed tensorflow from the provided binaries for Ubuntu/Linux 64-bit, GPU enabled, Python 2.7):
\n\nimport numpy as np\nfrom sklearn.cross_validation import train_test_split\nfrom tensorflow.contrib import learn\nimport tensorflow as tf\nimport logging\nlogging.getLogger().setLevel(logging.INFO)\n\n#Some fake data \nN=200\nX=np.array(range(N),dtype=np.float32)/(N/10)\nX=X[:,np.newaxis]\nY=np.sin(X.squeeze())+np.random.normal(0, 0.5, N)\n\nX_train, X_test, Y_train, Y_test = train_test_split(X, Y, \n train_size=0.8, \n test_size=0.2)\n\nval_monitor = learn.monitors.ValidationMonitor(X_test, Y_test,early_stopping_rounds=200)\nreg=learn.DNNRegressor(hidden_units=[10,10],activation_fn=tf.tanh,model_dir=\"tmp/\")\nreg.fit(X_train,Y_train,steps=5000,monitors=[val_monitor])\nprint \"train error:\", reg.evaluate(X_train, Y_train)\nprint \"test error:\", reg.evaluate(X_test, Y_test)\n\n\nThe code runs but only the first validation step is done properly, then validation always returns the same value even if training is actually going fine which can be checked by running an evaluation on the test set at the end. The following message also appears for each validation step.
\n\nINFO:tensorflow:Input iterator is exhausted. \n\n\nAny help is welcome!\nThanks,\nDavid
\n", "Lable": "D"} {"QuestionId": 38503423, "AnswerCount": 1, "Tags": "I have my webpack config loaders as like this:
\n\n//config for css\n{ test: /\\.css$/, loader: \"style-loader!css-loader\" },\n{ test: /\\.png$/, loader: \"url-loader?limit=100000\" },\n{ test: /\\.jpg$/, loader: \"file-loader\" }\n\n\nand in my React component I have:
\n\nimport styles from \"../../../css/style.css\"\n\n\nand my style.css looks like:
#box {\n}\n\n\nbut in my react component if I refer to styles its just returning {}, I expect it should have box key. But it doesn't, where I'm making mistake?
I am working on recurrent neural network in Tensorflow.\nI have a tensor H which stores hidden states for a batch of inputs.
Assume that H is of size a*b. How do I reset rows of H, given in a list, to zeros?
e.g. if a list is [1, 2] I want to reset only those rows of H to zeros, leaving others intact.
I am developing small department-size application using Web Forms. Technology choice comes form the past, as application is based on an old one already existing + Web Forms seem to be extremely fast and efficient for our case.
\n\nDefault template in VS 2015 creates all login pages, etc. I assign roles to users. And the question comes how to protect specific folder or page to be available only for users with specific role?
\n\nThe only idea I have is:
\n\nIf Not Page.User.Identity.IsAuthenticated or Not Page.User.Identity.IsInRole(\"MyRole\") Then\n Response.Redirect(\"~/Account/Login?ReturnUrl=\" & Server.UrlEncode(Request.Url.ToString())\nEnd If\n\n\nThis is not convenient having many pages in application. I saw MVC solves this with attribute
\n\n[Authorize( Roles = Constants.ADMIN )]\n\n\nWhat is the best way to achieve this? Please advise.
\n", "Lable": "No"} {"QuestionId": 38714935, "AnswerCount": 2, "Tags": "This two functions conflicts with each other. \nIs there a workaround for this issue?
\n\ninline fun <reified T: Any> foo() = ...\ninline fun <reified T: Any, reified I: Any> foo() = ...\n\n\nThanks!
\n\nEdit:
\n\nI found convenient(at least for me) solution for this issue:
\n\ninline fun <reified T: Any> foo() = foo<T, MyDefaultType>()\ninline fun <reified T: Any, reified I: Any> foo(type1: KClass<T> = T::class, type2: KClass<I> = I::class) = ...\n\n\nIt can be even concise if you choose to add only one parameter.
\n\nLater you can use it like this:
\n\nval x = foo<A, B>()\nval y = foo<C>()\n\n\nThat's what I need.
\n", "Lable": "No"} {"QuestionId": 38722799, "AnswerCount": 0, "Tags": "In the documentation of Tensorflow's Session.run() function (link here) it is said that the fetches argument can be a list of nodes, to get the output of multiple graph nodes at the same time, instead of just one.
My question is, if such nodes are related and have dependencies between them, will the computation be shared or each node will have it's own computation?
\n\nLet my explain better with an example. Suppose we have the following computation graph:
\n\nimport tensorflow as tf\na = tf.placeholder(\"float\")\nb = tf.mul(a,3)\nc = tf.mul(b,-2)\n\nsess = tf.Session()\nprint(sess.run([b, c], feed_dict={a:2}))\n\n\nThe output will be
\n\n[6.0, -12.0]\n\n\nBut will the computation to get b be reused to get c? Or will b and c be computed independently even though they share some operations?
My guess is that the computation will be reused, but I can't find the answer in the documentation.
\n\nThanks!
\n", "Lable": "D"} {"QuestionId": 38725224, "AnswerCount": 2, "Tags": "I try to make a sentence classifier using tensorflow as in the example of the official site tf.contrib.learn Quickstart but using my own data, first I convert all my data (which are strings of varying lengths) to ids through the use of dictionaries and so transform each sentence in an array of integers.
\n\nEach record for training has its own assigned label.
\n\nThe problem is that predictions are not exact, only some, but others even when the input is equal to a record of the training base the result is wrong.
\nMy code looks something like this:
def launchModelData(values, labels, sample, actionClasses):\n\n #Tensor for trainig data\n v = tf.Variable(values)\n l = tf.Variable(labels)\n\n #Data Sample\n s = tf.Variable(sample)\n\n # Build 3 layer DNN with 10, 20, 10 units respectively.\n classifier = tf.contrib.learn.DNNClassifier(hidden_units=[10, 20, 10], n_classes=actionClasses)\n\n # Add an op to initialize the variables.\n init_op = tf.initialize_all_variables()\n\n # Later, when launching the model\n with tf.Session() as sess:\n # Run the init operation.\n sess.run(init_op)\n\n # Fit model.\n classifier.fit(x=v.eval(), y=l.eval(), steps=200)\n\n # Classify one new sample.\n new_sample = np.array(s.eval(), dtype=int)\n y = classifier.predict(new_sample)\n print ('Predictions: {}'.format(str(y)))\n\n return y\n\n\nValues and classes axample:
\n\n[0 1] 0 \n[0 2] 0 \n[0 4] 0 \n[7 8] 1 \n[7 9] 1 \n[ 7 13] 1 \n[14 15] 2 \n[14 16] 2 \n[14 18] 2 \n[20 21] 3 \n[26 27] 5 \n[29 27] 5 \n[31 32] 5 \n... \n\n\nI'm new to tensorflow so I try to make it less complex possible, any help will be welcome.
\n\nEDIT
\nMy actual training data is this.
I try it with 8 classes and the predictions were fine, so maybe i need a bigger corpus, i will try and show my outputs in a new edit.
\n\nEDIT2
\n\nNow i use a composition of five layer [n,2n,4n,8n,16n] where n = Classes and steps = 20000, this reduce the loss and increase the accuracy really well but again it just work with a few targets (10 aprox) with a bigger amount the predictions become wrong.
\n", "Lable": "D"} {"QuestionId": 38751185, "AnswerCount": 1, "Tags": "I'm trying to create a LinearClassifer with a sparse binary numpy coo matrix (reports) using a SparseTensor. This is with TensorFlow 0.9.0
\n\nI do this as follows:
\n\nreports_indices = list()\nrows,cols = reports.nonzero()\nfor row,col in zip(rows,cols):\n reports_indices.append([row,col])\n\nx_sparsetensor = tf.SparseTensor(\n indices=reports_indices,\n values=[1] * len(reports_indices),\n shape=[reports.shape[0],reports.shape[1]])\n\n\nThe dimensions of reports is 10K by 1.5K.
\n\nI then setup the LinearClassifier as follows:
\n\nm = tf.contrib.learn.LinearClassifier()\n\nm.fit(x=x_sparsetensor,y=response_vector.todense(),input_fn=None)\n\n\nResponse vector is binary and has a length of 10K. This results in the following error:
\n\nTraceback (most recent call last):\n File \"ddi_prr.py\", line 38, in <module>\n m.fit(x=x_sparsetensor,y=response_vector.todense(),input_fn=None)\n File \"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py\", line 173, in fit\n input_fn, feed_fn = _get_input_fn(x, y, batch_size)\n File \"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py\", line 67, in _get_input_fn\n x, y, n_classes=None, batch_size=batch_size)\n File \"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/io/data_feeder.py\", line 117, in setup_train_data_feeder\n X, y, n_classes, batch_size, shuffle=shuffle, epochs=epochs)\n File \"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/io/data_feeder.py\", line 240, in __init__\n batch_size)\n File \"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/io/data_feeder.py\", line 44, in _get_in_out_shape\n x_shape = list(x_shape[1:]) if len(x_shape) > 1 else [1]\nTypeError: object of type 'Tensor' has no len()\n\n\nIs my construction incorrect for some reason? It seems that LinearClassifier.fit can't be instantiated with a SparseTensor for x, is that true? Thanks in advance for any help.
\n", "Lable": "D"} {"QuestionId": 38751736, "AnswerCount": 2, "Tags": "After reading this github issue I feel like I'm missing something in my understanding on queues:
\n\nhttps://github.com/tensorflow/tensorflow/issues/3009
\n\nI thought that when loading data into a queue, it will get pre-transferred to the GPU while the last batch is getting computed, so that there is virtually no bandwidth bottleneck, assuming computation takes longer than the time to load the next batch.
\n\nBut the above link suggests that there is an expensive copy from queue into the graph (numpy <-> TF) and that it would be faster to load the files into the graph and do preprocessing there instead. But that doesn't make sense to me. Why does it matter if I load a 256x256 image from file vs a raw numpy array? If anything, I would think that the numpy version is faster. What am I missing?
\n", "Lable": "D"} {"QuestionId": 38812231, "AnswerCount": 0, "Tags": "In my database, I have a table Article with 10 columns. I also have a table Item that has an Article as a foreign key - one of the fields in Item is the Article_ID field. However, the Item also has another field from the Article, and that is the Article_Price.
So the situation is that I have the field Article_Price both in my Article and Item table, even though the Item already has the Article as a FK.
The question is - how to embed only the Article_Price field in my Item class, and not the entire Article (since it already exists as a separate table)?
I understand that for embedding the whole Article, the code would look something like the following.
@Entity\n@Embeddable\npublic class Article {\n //...\n\n\n@Entity\npublic class Item {\n\n @Embedded\n Article article;\n\n\nBut I need only the Article_Price to be embedded, and the Article to remain as the FK. Something like this:
Item.java
\n\n@Entity\n@Table(name = \"Item\")\npublic class Item {\n\n @Id \n @Column(name = \"Item_ID\", nullable = false)\n private int id;\n\n @ManyToOne\n @JoinColumn(name = \"Article_ID\")\n private Article article;\n\n @Embedded // I want only this attribute from Article to embedded here\n @Column(name = \"Article_Price\")\n private float articlePrice;\n\n\nArticle.java
\n\n@Entity\n@Table (name = \"Article\")\npublic class Article {\n\n @Id\n private int id;\n\n @Embeddable // I want only this attribute to be embeddable\n @Column(name = \"Article_Price\", nullable = false)\n private float price;\n\n\nHow can I achieve this?
\n\nI did the attribute override in my Item.java like this:
@ManyToOne\n @JoinColumn(name = \"Article_ID\", nullable = false)\n @Embedded // embedding only the price field\n @AttributeOverride(name = \"price\", column = @Column(name = \"Article_Price\", nullable = false))\n private Article article;\n\n\nI am now able to store such Item object to the DB, and it maps to the correct Article_ID but the Article_Price field is always 0. So it doesn't copy the actual Article_Price from the Article table, but just defaults it. Any idea how to solve this?
I am saving like this:
\n\n Session s = sf.openSession();\n// \n// // saving to the DB\n s.beginTransaction();\n\n Article article = s.get(Article.class, 5391); // 5391 is the ID\n Item item = new Item(6.00f, article, 18.00f);\n\n s.save(item);\n\n\nThe problem is that the Article with the ID 5391 has the Article_Price property value of 150, and when I save the Item with referenced this Article, in the Item's property Article_Price it has the value of 0. It should also be 150.
Heyy all. I am trying to do an if/else statement for my fileupload function on my Edit Profile page in my ASP.net webpage.
\n\nHere is my code:
\n\nprotected void btnContinue_Click(object sender, EventArgs e)\n{\n //Declaration of variable to update Profile Image\n string imageName, newContact;\n imageName = FileUpload1.FileName.ToString();\n newContact = tbMobile.Text.ToString();\n\n username = (String)Session[\"NonAdmin\"];\n MySqlConnection mcon = new MySqlConnection(\"server=182.50.133.91;user id=Jonathan;password=jon123;persistsecurityinfo=True;database=ajactrac_;allowuservariables=True\");\n MySqlDataAdapter sda = new MySqlDataAdapter(\"select * from pointofcontact where Username = '\" + username.ToString() + \"'\", mcon);\n DataTable dt = new DataTable();\n sda.Fill(dt);\n if (dt.Rows.Count.ToString() == \"1\")\n {\n\n MySqlCommand command = mcon.CreateCommand();\n MySqlCommand command1 = mcon.CreateCommand();\n MySqlCommand command2 = mcon.CreateCommand();\n MySqlCommand command3 = mcon.CreateCommand();\n MySqlCommand command4 = mcon.CreateCommand();\n MySqlCommand command5 = mcon.CreateCommand();\n MySqlCommand command6 = mcon.CreateCommand();\n MySqlCommand command7 = mcon.CreateCommand();\n\n command.CommandText = \"update pointofcontact set Password = ?pwd where Username = '\" + username.ToString() + \"'\";\n command1.CommandText = \"update pointofcontact set FirstName = ?firstname where Username = '\" + username.ToString() + \"'\";\n command2.CommandText = \"update pointofcontact set LastName = ?lastname where Username = '\" + username.ToString() + \"'\";\n command3.CommandText = \"update pointofcontact set ContactNumber = ?contact where Username = '\" + username.ToString() + \"'\";\n command4.CommandText = \"update pointofcontact set EmailAddress = ?email where Username = '\" + username.ToString() + \"'\";\n command5.CommandText = \"update pointofcontact set Address = ?address where Username = '\" + username.ToString() + \"'\";\n command6.CommandText = \"update pointofcontact set BackupContactNumber = ?backupnumber where Username = '\" + username.ToString() + \"'\";\n command7.CommandText = \"update pointofcontact set ProfilePic = ?newimage where Username = '\" + username.ToString() + \"'\";\n\n mcon.Open();\n if (tbNewPassword.Text == \"\")\n {\n command.Parameters.AddWithValue(\"?pwd\", tbOldPassword.Text.Trim());\n }\n else\n {\n command.Parameters.AddWithValue(\"?pwd\", tbNewPassword.Text.Trim());\n }\n\n if(tbNewFirstName.Text == \"\")\n {\n command1.Parameters.AddWithValue(\"?firstname\", tbFirstName.Text.Trim());\n }\n else\n {\n command1.Parameters.AddWithValue(\"?firstname\", tbNewFirstName.Text.Trim());\n }\n\n if(tbNewLastName.Text == \"\")\n {\n command2.Parameters.AddWithValue(\"?lastname\", tbLastName.Text.Trim());\n }\n else\n {\n command2.Parameters.AddWithValue(\"?lastname\", tbNewLastName.Text.Trim());\n }\n\n if(tbNewContact.Text == \"\")\n {\n command3.Parameters.AddWithValue(\"?contact\", tbMobile.Text.Trim());\n }\n else\n {\n command3.Parameters.AddWithValue(\"?contact\", tbNewContact.Text.Trim());\n }\n\n if(tbNewEmail.Text == \"\")\n {\n command4.Parameters.AddWithValue(\"?email\", tbEmail.Text.Trim());\n }\n else\n {\n command4.Parameters.AddWithValue(\"?email\", tbNewEmail.Text.Trim());\n }\n\n if(tbNewAddress.Text == \"\")\n {\n command5.Parameters.AddWithValue(\"?address\", tbAddress.Text.Trim());\n }\n else\n {\n command5.Parameters.AddWithValue(\"?address\", tbNewAddress.Text.Trim());\n }\n\n if(tbNewBackupContact.Text == \"\")\n {\n command6.Parameters.AddWithValue(\"?backupnumber\", tbBackupContact.Text.Trim());\n }\n else\n {\n command6.Parameters.AddWithValue(\"?backupnumber\", tbNewBackupContact.Text.Trim());\n }\n\n\n FileUpload1.PostedFile.SaveAs(Server.MapPath(\"~/Images/\") + imageName);\n command7.Parameters.AddWithValue(\"?newimage\", imageName);\n\n command.ExecuteNonQuery();\n command1.ExecuteNonQuery();\n command2.ExecuteNonQuery();\n command3.ExecuteNonQuery();\n command4.ExecuteNonQuery();\n command5.ExecuteNonQuery();\n command6.ExecuteNonQuery();\n command7.ExecuteNonQuery();\n\n mcon.Close();\n string javaScript = \"<script language=JavaScript>\\n\" + \"alert('Profile Updated!');\\n\" + \"</script>\";\n RegisterStartupScript(\"xyz\", javaScript);\n }\n else\n {\n string javaScript = \"<script language=JavaScript>\\n\" + \"alert('Some Error Occured! Profile Not Updated!');\\n\" + \"</script>\";\n RegisterStartupScript(\"xyz\", javaScript);\n }\n tbNewPassword.Text = \"\";\n\n\n\n\n}\n\n\nI had planned to use the if else statement for my fileupload function such that if the user has not uploaded a new picture, he/she would be still able to update their profile.
\n\nCurrently when I try to edit a user's profile, this error message comes out.
\n", "Lable": "No"}