python3.7安装的 tensorflow缺少tensorflow.app.flags怎么解决? 40C

图片说明

如图缺少flags

试过卸载重装
也试过卸载了从https://www.lfd.uci.edu/~gohlke/pythonlibs/下载安装

可是问题依旧
系统win10 python3.7

2个回答

你卸载了原来的tensorflow 然后 使用pip install tensorflow 安装试试?

或者试试用nanconda

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
module 'tensorflow' has no attribute 'flags'有大佬知道这是为啥报错吗?

import tensorflow as tf flags = tf.flags 结果报上述的错了,改成flags = tf.app.flags, 就报module 'tensorflow' has no attribute 'app'的错, 我的tensorflow是最新版本的,应该不是版本的问题吧。

tf.app.run()显示tensorflow未配置app

代码最后加了 ``` if __name__ == '__main__': tf.app.run() ``` 显示错误 ``` AttributeError: module 'tensorflow' has no attribute 'app' ``` 一直没找到怎么回事,也在cmd里试了pip install app,也不行。想请问下这是什么问题导致的。 ![图片说明](https://img-ask.csdn.net/upload/201911/06/1573042024_319476.png) ![图片说明](https://img-ask.csdn.net/upload/201911/06/1573041926_866237.png)

使用tesorflow中model_main.py遇到的问题!

直接上代码了 ``` D:\tensorflow\models\research\object_detection>python model_main.py --pipeline_config_path=E:\python_demo\pedestrian_demo\pedestrian_train\models\pipeline.config --model_dir=E:\python_demo\pedestrian_demo\pedestrian_train\models\train --num_train_steps=5000 --sample_1_of_n_eval_examples=1 --alsologstderr Traceback (most recent call last): File "model_main.py", line 109, in <module> tf.app.run() File "C:\anaconda\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "model_main.py", line 71, in main FLAGS.sample_1_of_n_eval_on_train_examples)) File "D:\ssd-detection\models-master\research\object_detection\model_lib.py", line 589, in create_estimator_and_inputs pipeline_config_path, config_override=config_override) File "D:\ssd-detection\models-master\research\object_detection\utils\config_util.py", line 98, in get_configs_from_pipeline_file text_format.Merge(proto_str, pipeline_config) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 574, in Merge descriptor_pool=descriptor_pool) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 631, in MergeLines return parser.MergeLines(lines, message) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 654, in MergeLines self._ParseOrMerge(lines, message) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 676, in _ParseOrMerge self._MergeField(tokenizer, message) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 801, in _MergeField merger(tokenizer, message, field) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 875, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 801, in _MergeField merger(tokenizer, message, field) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 875, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 801, in _MergeField merger(tokenizer, message, field) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 875, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "C:\anaconda\lib\site-packages\google\protobuf\text_format.py", line 768, in _MergeField (message_descriptor.full_name, name)) google.protobuf.text_format.ParseError: 35:7 : Message type "object_detection.protos.SsdFeatureExtractor" has no field named "batch_norm_trainable". ``` 这个错误怎么解决,求大神指导~

深度学习Tensorflow-DCGAN训练图片出错

Traceback (most recent call last): File "main.py", line 147, in <module> tf.app.run() File "/home/Natalie2/anaconda3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "main.py", line 70, in main flags_dict = {k:FLAGS[k].value for k in FLAGS} TypeError: '_FlagValues' object is not iterable

如何可视化tensorflow版的fater rcnn的训练过程?

小白一枚,github下的faster rcnn tf版在win10系统上,代码里没有输出训练日志的语句无log文件, 想问一下怎么添加语句可以通过tensorboard显示?下为train代码 import time import tensorflow as tf import numpy as np from tensorflow.python import pywrap_tensorflow import lib.config.config as cfg from lib.datasets import roidb as rdl_roidb from lib.datasets.factory import get_imdb from lib.datasets.imdb import imdb as imdb2 from lib.layer_utils.roi_data_layer import RoIDataLayer from lib.nets.vgg16 import vgg16 from lib.utils.timer import Timer try: import cPickle as pickle except ImportError: import pickle import os def get_training_roidb(imdb): """Returns a roidb (Region of Interest database) for use in training.""" if True: print('Appending horizontally-flipped training examples...') imdb.append_flipped_images() print('done') print('Preparing training data...') rdl_roidb.prepare_roidb(imdb) print('done') return imdb.roidb def combined_roidb(imdb_names): """ Combine multiple roidbs """ def get_roidb(imdb_name): imdb = get_imdb(imdb_name) print('Loaded dataset `{:s}` for training'.format(imdb.name)) imdb.set_proposal_method("gt") print('Set proposal method: {:s}'.format("gt")) roidb = get_training_roidb(imdb) return roidb roidbs = [get_roidb(s) for s in imdb_names.split('+')] roidb = roidbs[0] if len(roidbs) > 1: for r in roidbs[1:]: roidb.extend(r) tmp = get_imdb(imdb_names.split('+')[1]) imdb = imdb2(imdb_names, tmp.classes) else: imdb = get_imdb(imdb_names) return imdb, roidb class Train: def __init__(self): # Create network if cfg.FLAGS.net == 'vgg16': self.net = vgg16(batch_size=cfg.FLAGS.ims_per_batch) else: raise NotImplementedError self.imdb, self.roidb = combined_roidb("voc_2007_trainval") self.data_layer = RoIDataLayer(self.roidb, self.imdb.num_classes) self.output_dir = cfg.get_output_dir(self.imdb, 'default') def train(self): # Create session tfconfig = tf.ConfigProto(allow_soft_placement=True) tfconfig.gpu_options.allow_growth = True sess = tf.Session(config=tfconfig) with sess.graph.as_default(): tf.set_random_seed(cfg.FLAGS.rng_seed) layers = self.net.create_architecture(sess, "TRAIN", self.imdb.num_classes, tag='default') loss = layers['total_loss'] lr = tf.Variable(cfg.FLAGS.learning_rate, trainable=False) momentum = cfg.FLAGS.momentum optimizer = tf.train.MomentumOptimizer(lr, momentum) gvs = optimizer.compute_gradients(loss) # Double bias # Double the gradient of the bias if set if cfg.FLAGS.double_bias: final_gvs = [] with tf.variable_scope('Gradient_Mult'): for grad, var in gvs: scale = 1. if cfg.FLAGS.double_bias and '/biases:' in var.name: scale *= 2. if not np.allclose(scale, 1.0): grad = tf.multiply(grad, scale) final_gvs.append((grad, var)) train_op = optimizer.apply_gradients(final_gvs) else: train_op = optimizer.apply_gradients(gvs) # We will handle the snapshots ourselves self.saver = tf.train.Saver(max_to_keep=100000) # Write the train and validation information to tensorboard # writer = tf.summary.FileWriter(self.tbdir, sess.graph) # valwriter = tf.summary.FileWriter(self.tbvaldir) # Load weights # Fresh train directly from ImageNet weights print('Loading initial model weights from {:s}'.format(cfg.FLAGS.pretrained_model)) variables = tf.global_variables() # Initialize all variables first sess.run(tf.variables_initializer(variables, name='init')) var_keep_dic = self.get_variables_in_checkpoint_file(cfg.FLAGS.pretrained_model) # Get the variables to restore, ignorizing the variables to fix variables_to_restore = self.net.get_variables_to_restore(variables, var_keep_dic) restorer = tf.train.Saver(variables_to_restore) restorer.restore(sess, cfg.FLAGS.pretrained_model) print('Loaded.') # Need to fix the variables before loading, so that the RGB weights are changed to BGR # For VGG16 it also changes the convolutional weights fc6 and fc7 to # fully connected weights self.net.fix_variables(sess, cfg.FLAGS.pretrained_model) print('Fixed.') sess.run(tf.assign(lr, cfg.FLAGS.learning_rate)) last_snapshot_iter = 0 timer = Timer() iter = last_snapshot_iter + 1 last_summary_time = time.time() while iter < cfg.FLAGS.max_iters + 1: # Learning rate if iter == cfg.FLAGS.step_size + 1: # Add snapshot here before reducing the learning rate # self.snapshot(sess, iter) sess.run(tf.assign(lr, cfg.FLAGS.learning_rate * cfg.FLAGS.gamma)) timer.tic() # Get training data, one batch at a time blobs = self.data_layer.forward() # Compute the graph without summary rpn_loss_cls, rpn_loss_box, loss_cls, loss_box, total_loss = self.net.train_step(sess, blobs, train_op) timer.toc() iter += 1 # Display training information if iter % (cfg.FLAGS.display) == 0: print('iter: %d / %d, total loss: %.6f\n >>> rpn_loss_cls: %.6f\n ' '>>> rpn_loss_box: %.6f\n >>> loss_cls: %.6f\n >>> loss_box: %.6f\n ' % \ (iter, cfg.FLAGS.max_iters, total_loss, rpn_loss_cls, rpn_loss_box, loss_cls, loss_box)) print('speed: {:.3f}s / iter'.format(timer.average_time)) if iter % cfg.FLAGS.snapshot_iterations == 0: self.snapshot(sess, iter ) def get_variables_in_checkpoint_file(self, file_name): try: reader = pywrap_tensorflow.NewCheckpointReader(file_name) var_to_shape_map = reader.get_variable_to_shape_map() return var_to_shape_map except Exception as e: # pylint: disable=broad-except print(str(e)) if "corrupted compressed block contents" in str(e): print("It's likely that your checkpoint file has been compressed " "with SNAPPY.") def snapshot(self, sess, iter): net = self.net if not os.path.exists(self.output_dir): os.makedirs(self.output_dir) # Store the model snapshot filename = 'vgg16_faster_rcnn_iter_{:d}'.format(iter) + '.ckpt' filename = os.path.join(self.output_dir, filename) self.saver.save(sess, filename) print('Wrote snapshot to: {:s}'.format(filename)) # Also store some meta information, random state, etc. nfilename = 'vgg16_faster_rcnn_iter_{:d}'.format(iter) + '.pkl' nfilename = os.path.join(self.output_dir, nfilename) # current state of numpy random st0 = np.random.get_state() # current position in the database cur = self.data_layer._cur # current shuffled indeces of the database perm = self.data_layer._perm # Dump the meta info with open(nfilename, 'wb') as fid: pickle.dump(st0, fid, pickle.HIGHEST_PROTOCOL) pickle.dump(cur, fid, pickle.HIGHEST_PROTOCOL) pickle.dump(perm, fid, pickle.HIGHEST_PROTOCOL) pickle.dump(iter, fid, pickle.HIGHEST_PROTOCOL) return filename, nfilename if __name__ == '__main__': train = Train() train.train()

ValueError: None values not supported.

Traceback (most recent call last): File "document_summarizer_training_testing.py", line 296, in <module> tf.app.run() File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "document_summarizer_training_testing.py", line 291, in main train() File "document_summarizer_training_testing.py", line 102, in train model = MY_Model(sess, len(vocab_dict)-2) File "/home/lyliu/Refresh-master-self-attention/my_model.py", line 70, in __init__ self.train_op_policynet_expreward = model_docsum.train_neg_expectedreward(self.rewardweighted_cross_entropy_loss_multi File "/home/lyliu/Refresh-master-self-attention/model_docsum.py", line 835, in train_neg_expectedreward grads_and_vars_capped_norm = [(tf.clip_by_norm(grad, 5.0), var) for grad, var in grads_and_vars] File "/home/lyliu/Refresh-master-self-attention/model_docsum.py", line 835, in <listcomp> grads_and_vars_capped_norm = [(tf.clip_by_norm(grad, 5.0), var) for grad, var in grads_and_vars] File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/ops/clip_ops.py", line 107,rm t = ops.convert_to_tensor(t, name="t") File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 676o_tensor as_ref=False) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 741convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", onstant tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "/home/lyliu/anaconda3/envs/tensorflowgpu/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", ake_tensor_proto raise ValueError("None values not supported.") ValueError: None values not supported. 使用tensorflow gpu版本 tensorflow 1.2.0。希望找到解决方法或者出现这个错误的原因

在运行tensorflow MNIST 里的例子时报错

/tensorflow-master/tensorflow/examples/tutorials/mnist$ python fully_connected_feed.py /usr/local/lib/python2.7/dist-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20. "This module will be removed in 0.20.", DeprecationWarning) Traceback (most recent call last): File "fully_connected_feed.py", line 277, in <module> tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) TypeError: run() got an unexpected keyword argument 'argv' 我是从GITHUB上下载的包,代码也没改,运行的fully_connceted_feed.py时报错

tensorflow.GraphDef was modified concurrently during serialization

![图片说明](https://img-ask.csdn.net/upload/201909/17/1568650242_211346.png) # Create a saver object which will save all the variables saver = tf.train.Saver(keep_checkpoint_every_n_hours=1.0) if FLAGS.pre_trained_checkpoint: train_utils.restore_fn(FLAGS) start_epoch = 0 # Get the number of training/validation steps per epoch tr_batches = int(MODELNET_TRAIN_DATA_SIZE / FLAGS.batch_size) if MODELNET_TRAIN_DATA_SIZE % FLAGS.batch_size > 0: tr_batches += 1 val_batches = int(MODELNET_VALIDATE_DATA_SIZE / FLAGS.batch_size) if MODELNET_VALIDATE_DATA_SIZE % FLAGS.batch_size > 0: val_batches += 1 # The filenames argument to the TFRecordDataset initializer can either be a string, # a list of strings, or a tf.Tensor of strings. training_filenames = os.path.join(FLAGS.dataset_dir, 'train.record') validate_filenames = os.path.join(FLAGS.dataset_dir, 'validate.record') ################## # Training loop. ################## for training_epoch in range(start_epoch, FLAGS.how_many_training_epochs): print("-------------------------------------") print(" Epoch {} ".format(training_epoch)) print("-------------------------------------") sess.run(iterator.initializer, feed_dict={filenames: training_filenames}) for step in range(tr_batches): # Pull the image batch we'll use for training. train_batch_xs, train_batch_ys = sess.run(next_batch) handle = sess.partial_run_setup([d_scores, final_desc, learning_rate, summary_op, accuracy, total_loss, grad_summ_op, train_op], [X, final_X, ground_truth, grouping_scheme, grouping_weight, is_training, is_training2, dropout_keep_prob]) scores, final = sess.partial_run(handle, [d_scores, final_desc], feed_dict={ X: train_batch_xs, is_training: True} ) schemes = gvcnn.grouping_scheme(scores, NUM_GROUP, FLAGS.num_views) weights = gvcnn.grouping_weight(scores, schemes) # Run the graph with this batch of training data. lr, train_summary, train_accuracy, train_loss, grad_vals, _ = \ sess.partial_run(handle, [learning_rate, summary_op, accuracy, total_loss, grad_summ_op, train_op], feed_dict={ final_X: final, ground_truth: train_batch_ys, grouping_scheme: schemes, grouping_weight: weights, is_training2: True, dropout_keep_prob: 0.8} ) train_writer.add_summary(train_summary, training_epoch) train_writer.add_summary(grad_vals, training_epoch) tf.logging.info('Epoch #%d, Step #%d, rate %.10f, accuracy %.1f%%, loss %f' % (training_epoch, step, lr, train_accuracy * 100, train_loss)) # Save the model checkpoint periodically. if (training_epoch <= FLAGS.how_many_training_epochs-1): checkpoint_path = os.path.join(FLAGS.train_logdir, FLAGS.ckpt_name_to_save) tf.logging.info('Saving to "%s-%d"', checkpoint_path, training_epoch) saver.save(sess, checkpoint_path, global_step=training_epoch) ``` ```

theano或Python环境的问题,运行train.py出现一些问题,求大神指导

wangj@liutl:~/Work/NSC-master/NSC/src$ THEANO_FLAGS="floatX=float32,device=gpu" python train.py IMDB 10 Using gpu device 0: GeForce GTX TITAN Black (CNMeM is disabled, cuDNN Version is too old. Update to v5, was 4004.) data loaded. Traceback (most recent call last): File "train.py", line 15, in <module> model = LSTMModel(voc.size,trainset, devset, dataname, classes, None) File "/home/wangj/Work/NSC-master/NSC/src/LSTMModel.py", line 61, in __init__ updates=updates, File "/usr/local/lib/python2.7/dist-packages/theano/compile/function.py", line 320, in function output_keys=output_keys) File "/usr/local/lib/python2.7/dist-packages/theano/compile/pfunc.py", line 479, in pfunc output_keys=output_keys) File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 1777, in orig_function defaults) File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 1641, in create input_storage=input_storage_lists, storage_map=storage_map) File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 690, in make_thunk storage_map=storage_map)[:3] File "/usr/local/lib/python2.7/dist-packages/theano/gof/vm.py", line 1003, in make_all no_recycling)) File "/usr/local/lib/python2.7/dist-packages/theano/scan_module/scan_op.py", line 913, in make_thunk from . import scan_perform_ext File "/usr/local/lib/python2.7/dist-packages/theano/scan_module/scan_perform_ext.py", line 141, in <module> from scan_perform.scan_perform import * File "__init__.pxd", line 155, in init theano.scan_module.scan_perform (/home/wangj/.theano/compiledir_Linux-3.13--generic-x86_64-with-Ubuntu-14.04-trusty-x86_64-2.7.6-64/scan_perform/mod.cpp:9984) ValueError: ('The following error happened while compiling the node', forall_inplace,gpu,scan_fn}(Elemwise{minimum,no_inplace}.0, GpuDimShuffle{0,1,x}.0, GpuSubtensor{int64:int64:int8}.0, GpuIncSubtensor{InplaceSet;:int64:}.0, GpuIncSubtensor{InplaceSet;:int64:}.0, Wf1, Wf2, Wc1, Wc2, Wi1, Wi2, Wo1, Wo2, GpuDimShuffle{x,0}.0, GpuDimShuffle{x,0}.0, GpuDimShuffle{x,0}.0, GpuDimShuffle{x,0}.0), '\n', 'numpy.dtype has the wrong size, try recompiling')

tensorflow cifar10教程如何实现断点续训?我希望每次能从上次的结果继续训练

cifar10_train.py FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_string('train_dir', 'D:/tmp/cifar10_trainn', """Directory where to write event logs """ """and checkpoint.""") tf.app.flags.DEFINE_integer('max_steps', 100000, """Number of batches to run.""") tf.app.flags.DEFINE_boolean('log_device_placement', False, """Whether to log device placement.""") tf.app.flags.DEFINE_integer('log_frequency', 10, """How often to log results to the console.""") def train(): """Train CIFAR-10 for a number of steps.""" with tf.Graph().as_default(): global_step = tf.train.get_or_create_global_step() # Get images and labels for CIFAR-10. # Force input pipeline to CPU:0 to avoid operations sometimes ending up on # GPU and resulting in a slow down. with tf.device('/cpu:0'): images, labels = cifar10.distorted_inputs() # Build a Graph that computes the logits predictions from the # inference model. logits = cifar10.inference(images) # Calculate loss. loss = cifar10.loss(logits, labels) # Build a Graph that trains the model with one batch of examples and # updates the model parameters. train_op = cifar10.train(loss, global_step) class _LoggerHook(tf.train.SessionRunHook): """Logs loss and runtime.""" def begin(self): self._step = -1 self._start_time = time.time() def before_run(self, run_context): self._step += 1 return tf.train.SessionRunArgs(loss) # Asks for loss value. def after_run(self, run_context, run_values): if self._step % FLAGS.log_frequency == 0: current_time = time.time() duration = current_time - self._start_time self._start_time = current_time loss_value = run_values.results examples_per_sec = FLAGS.log_frequency * FLAGS.batch_size / duration sec_per_batch = float(duration / FLAGS.log_frequency) format_str = ('%s: step %d, loss = %.2f (%.1f examples/sec; %.3f ' 'sec/batch)') print (format_str % (datetime.now(), self._step, loss_value, examples_per_sec, sec_per_batch)) saver = tf.train.Saver() with tf.train.MonitoredTrainingSession( checkpoint_dir=FLAGS.train_dir, hooks=[tf.train.StopAtStepHook(last_step=FLAGS.max_steps), tf.train.NanTensorHook(loss), _LoggerHook()], config=tf.ConfigProto( log_device_placement=FLAGS.log_device_placement)) as mon_sess: while not mon_sess.should_stop(): mon_sess.run(train_op) def main(argv=None): # pylint: disable=unused-argument cifar10.maybe_download_and_extract() if tf.gfile.Exists(FLAGS.train_dir): tf.gfile.DeleteRecursively(FLAGS.train_dir) tf.gfile.MakeDirs(FLAGS.train_dir) train() if __name__ == '__main__': tf.app.run()

Mac下的Anaconda 无法使用matplotlib.pyplot

File "/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py", line 891, in __getitem__ from matplotlib import pyplot as plt File "/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 32, in <module> import matplotlib.colorbar File "/anaconda3/lib/python3.6/site-packages/matplotlib/colorbar.py", line 28, in <module> import matplotlib.artist as martist AttributeError: module 'matplotlib' has no attribute 'artist'

python3 爬照片報錯TypeError: expected string or bytes-like object

``` #!/usr/local/bin/python3.7 import urllib.request as urlre import re def open_url(url): req = urlre.Request(url) req.add_header('User-Agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36') page = urlre.urlopen(req) html = page.read().decode('utf-8') print(type(html)) return html def get_img(html): p = r'src="(.+?\.jpg)" pic_ex' imgsa = re.compile(p) imglist = re.findall(imgsa,html) return imglist for each in imglist: print(each) x = 0 for each in imglist: urlre.urlretrieve(each,':\\%s.jpg' % x) x += 1 if __name__ == "__main__": url ='http://tieba.baidu.com/p/2460150866' get_img(open_url) ``` return _compile(pattern, flags).findall(string) TypeError: expected string or bytes-like object

我的mnist运行报错,请问是那出现问题了?

from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse #解析训练和检测数据模块 import sys from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf FLAGS = None def main(_): # Import data mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True) # Create the model x = tf.placeholder(tf.float32, [None, 784]) #此函数可以理解为形参,用于定义过程,在执行的时候再赋具体的值 W = tf.Variable(tf.zeros([784, 10])) # tf.zeros表示所有的维度都为0 b = tf.Variable(tf.zeros([10])) y = tf.matmul(x, W) + b #对应每个分类概率值。 # Define loss and optimizer y_ = tf.placeholder(tf.float32, [None, 10]) # The raw formulation of cross-entropy, # # tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(tf.nn.softmax(y)), # reduction_indices=[1])) # # can be numerically unstable. # # So here we use tf.nn.softmax_cross_entropy_with_logits on the raw # outputs of 'y', and then average across the batch. cross_entropy = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y)) train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy) sess = tf.InteractiveSession() tf.global_variables_initializer().run() # Train for _ in range(1000): batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) # Test trained model correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels})) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--data_dir', type=str, default='/tmp/tensorflow/mnist/input_data', help='Directory for storing input data') FLAGS, unparsed = parser.parse_known_args() tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) ``` ```下面是报错: TimeoutError Traceback (most recent call last) ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 1317 h.request(req.get_method(), req.selector, req.data, headers, -> 1318 encode_chunked=req.has_header('Transfer-encoding')) 1319 except OSError as err: # timeout error ~\Anaconda3\envs\tensorflow\lib\http\client.py in request(self, method, url, body, headers, encode_chunked) 1238 """Send a complete request to the server.""" -> 1239 self._send_request(method, url, body, headers, encode_chunked) 1240 ~\Anaconda3\envs\tensorflow\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked) 1284 body = _encode(body, 'body') -> 1285 self.endheaders(body, encode_chunked=encode_chunked) 1286 ~\Anaconda3\envs\tensorflow\lib\http\client.py in endheaders(self, message_body, encode_chunked) 1233 raise CannotSendHeader() -> 1234 self._send_output(message_body, encode_chunked=encode_chunked) 1235 ~\Anaconda3\envs\tensorflow\lib\http\client.py in _send_output(self, message_body, encode_chunked) 1025 del self._buffer[:] -> 1026 self.send(msg) 1027 ~\Anaconda3\envs\tensorflow\lib\http\client.py in send(self, data) 963 if self.auto_open: --> 964 self.connect() 965 else: ~\Anaconda3\envs\tensorflow\lib\http\client.py in connect(self) 1399 self.sock = self._context.wrap_socket(self.sock, -> 1400 server_hostname=server_hostname) 1401 if not self._context.check_hostname and self._check_hostname: ~\Anaconda3\envs\tensorflow\lib\ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 400 server_hostname=server_hostname, --> 401 _context=self, _session=session) 402 ~\Anaconda3\envs\tensorflow\lib\ssl.py in __init__(self, sock, keyfile, certfile, server_side, cert_reqs, ssl_version, ca_certs, do_handshake_on_connect, family, type, proto, fileno, suppress_ragged_eofs, npn_protocols, ciphers, server_hostname, _context, _session) 807 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") --> 808 self.do_handshake() 809 ~\Anaconda3\envs\tensorflow\lib\ssl.py in do_handshake(self, block) 1060 self.settimeout(None) -> 1061 self._sslobj.do_handshake() 1062 finally: ~\Anaconda3\envs\tensorflow\lib\ssl.py in do_handshake(self) 682 """Start the SSL/TLS handshake.""" --> 683 self._sslobj.do_handshake() 684 if self.context.check_hostname: TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 During handling of the above exception, another exception occurred: URLError Traceback (most recent call last) <ipython-input-1-eaf9732201f9> in <module>() 57 help='Directory for storing input data') 58 FLAGS, unparsed = parser.parse_known_args() ---> 59 tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\platform\app.py in run(main, argv) 46 # Call the main function, passing through any arguments 47 # to the final program. ---> 48 _sys.exit(main(_sys.argv[:1] + flags_passthrough)) 49 50 <ipython-input-1-eaf9732201f9> in main(_) 15 def main(_): 16 # Import data ---> 17 mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True) 18 19 # Create the model ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py in read_data_sets(train_dir, fake_data, one_hot, dtype, reshape, validation_size, seed) 238 239 local_file = base.maybe_download(TRAIN_LABELS, train_dir, --> 240 SOURCE_URL + TRAIN_LABELS) 241 with open(local_file, 'rb') as f: 242 train_labels = extract_labels(f, one_hot=one_hot) ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py in maybe_download(filename, work_directory, source_url) 206 filepath = os.path.join(work_directory, filename) 207 if not gfile.Exists(filepath): --> 208 temp_file_name, _ = urlretrieve_with_retry(source_url) 209 gfile.Copy(temp_file_name, filepath) 210 with gfile.GFile(filepath) as f: ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py in wrapped_fn(*args, **kwargs) 163 for delay in delays(): 164 try: --> 165 return fn(*args, **kwargs) 166 except Exception as e: # pylint: disable=broad-except) 167 if is_retriable is None: ~\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\base.py in urlretrieve_with_retry(url, filename) 188 @retry(initial_delay=1.0, max_delay=16.0, is_retriable=_is_retriable) 189 def urlretrieve_with_retry(url, filename=None): --> 190 return urllib.request.urlretrieve(url, filename) 191 192 ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in urlretrieve(url, filename, reporthook, data) 246 url_type, path = splittype(url) 247 --> 248 with contextlib.closing(urlopen(url, data)) as fp: 249 headers = fp.info() 250 ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 221 else: 222 opener = _opener --> 223 return opener.open(url, data, timeout) 224 225 def install_opener(opener): ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in open(self, fullurl, data, timeout) 524 req = meth(req) 525 --> 526 response = self._open(req, data) 527 528 # post-process response ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in _open(self, req, data) 542 protocol = req.type 543 result = self._call_chain(self.handle_open, protocol, protocol + --> 544 '_open', req) 545 if result: 546 return result ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 502 for handler in handlers: 503 func = getattr(handler, meth_name) --> 504 result = func(*args) 505 if result is not None: 506 return result ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in https_open(self, req) 1359 def https_open(self, req): 1360 return self.do_open(http.client.HTTPSConnection, req, -> 1361 context=self._context, check_hostname=self._check_hostname) 1362 1363 https_request = AbstractHTTPHandler.do_request_ ~\Anaconda3\envs\tensorflow\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 1318 encode_chunked=req.has_header('Transfer-encoding')) 1319 except OSError as err: # timeout error -> 1320 raise URLError(err) 1321 r = h.getresponse() 1322 except: URLError: <urlopen error [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。> In [ ]:

用tensorflow做机器翻译时训练代码有问题

``` # -*- coding:UTF-8 -*- import tensorflow as tf src_path = 'D:/Python37/untitled1/train.tags.en-zh.en.deletehtml' trg_path = 'D:/Python37/untitled1/train.tags.en-zh.zh.deletehtml' SRC_TRAIN_DATA = 'D:/Python37/untitled1/train.tags.en-zh.en.deletehtml.segment' # 源语言输入文件 TRG_TRAIN_DATA = 'D:/Python37/untitled1/train.tags.en-zh.zh.deletehtml.segment' # 目标语言输入文件 CHECKPOINT_PATH = './model/seq2seq_ckpt' # checkpoint保存路径 HIDDEN_SIZE = 1024 # LSTM的隐藏层规模 NUM_LAYERS = 2 # 深层循环神经网络中LSTM结构的层数 SRC_VOCAB_SIZE = 10000 # 源语言词汇表大小 TRG_VOCAB_SIZE = 4000 # 目标语言词汇表大小 BATCH_SIZE = 100 # 训练数据batch的大小 NUM_EPOCH = 5 # 使用训练数据的轮数 KEEP_PROB = 0.8 # 节点不被dropout的概率 MAX_GRAD_NORM = 5 # 用于控制梯度膨胀的梯度大小上限 SHARE_EMB_AND_SOFTMAX = True # 在softmax层和词向量层之间共享参数 MAX_LEN = 50 # 限定句子的最大单词数量 SOS_ID = 1 # 目标语言词汇表中<sos>的ID """ function: 数据batching,产生最后输入数据格式 Parameters: file_path-数据路径 Returns: dataset- 每个句子-对应的长度组成的TextLineDataset类的数据集对应的张量 """ def MakeDataset(file_path): dataset = tf.data.TextLineDataset(file_path) # map(function, sequence[, sequence, ...]) -> list # 通过定义可以看到,这个函数的第一个参数是一个函数,剩下的参数是一个或多个序列,返回值是一个集合。 # function可以理解为是一个一对一或多对一函数,map的作用是以参数序列中的每一个元素调用function函数,返回包含每次function函数返回值的list。 # lambda argument_list: expression # 其中lambda是Python预留的关键字,argument_list和expression由用户自定义 # argument_list参数列表, expression 为函数表达式 # 根据空格将单词编号切分开并放入一个一维向量 dataset = dataset.map(lambda string: tf.string_split([string]).values) # 将字符串形式的单词编号转化为整数 dataset = dataset.map(lambda string: tf.string_to_number(string, tf.int32)) # 统计每个句子的单词数量,并与句子内容一起放入Dataset dataset = dataset.map(lambda x: (x, tf.size(x))) return dataset """ function: 从源语言文件src_path和目标语言文件trg_path中分别读取数据,并进行填充和batching操作 Parameters: src_path-源语言,即被翻译的语言,英语. trg_path-目标语言,翻译之后的语言,汉语. batch_size-batch的大小 Returns: dataset- 每个句子-对应的长度 组成的TextLineDataset类的数据集 """ def MakeSrcTrgDataset(src_path, trg_path, batch_size): # 首先分别读取源语言数据和目标语言数据 src_data = MakeDataset(src_path) trg_data = MakeDataset(trg_path) # 通过zip操作将两个Dataset合并为一个Dataset,现在每个Dataset中每一项数据ds由4个张量组成 # ds[0][0]是源句子 # ds[0][1]是源句子长度 # ds[1][0]是目标句子 # ds[1][1]是目标句子长度 #https://blog.csdn.net/qq_32458499/article/details/78856530这篇博客看一下可以细致了解一下Dataset这个库,以及.map和.zip的用法 dataset = tf.data.Dataset.zip((src_data, trg_data)) # 删除内容为空(只包含<eos>)的句子和长度过长的句子 def FilterLength(src_tuple, trg_tuple): ((src_input, src_len), (trg_label, trg_len)) = (src_tuple, trg_tuple) # tf.logical_and 相当于集合中的and做法,后面两个都为true最终结果才会为true,否则为false # tf.greater Returns the truth value of (x > y),所以以下所说的是句子长度必须得大于一也就是不能为空的句子 # tf.less_equal Returns the truth value of (x <= y),所以所说的是长度要小于最长长度 src_len_ok = tf.logical_and(tf.greater(src_len, 1), tf.less_equal(src_len, MAX_LEN)) trg_len_ok = tf.logical_and(tf.greater(trg_len, 1), tf.less_equal(trg_len, MAX_LEN)) return tf.logical_and(src_len_ok, trg_len_ok) #两个都满足才返回true # filter接收一个函数Func并将该函数作用于dataset的每个元素,根据返回值True或False保留或丢弃该元素,True保留该元素,False丢弃该元素 # 最后得到的就是去掉空句子和过长的句子的数据集 dataset = dataset.filter(FilterLength) # 解码器需要两种格式的目标句子: # 1.解码器的输入(trg_input), 形式如同'<sos> X Y Z' # 2.解码器的目标输出(trg_label), 形式如同'X Y Z <eos>' # 上面从文件中读到的目标句子是'X Y Z <eos>'的形式,我们需要从中生成'<sos> X Y Z'形式并加入到Dataset # 编码器只有输入,没有输出,而解码器有输入也有输出,输入为<sos>+(除去最后一位eos的label列表) # 例如train.en最后都为2,id为2就是eos def MakeTrgInput(src_tuple, trg_tuple): ((src_input, src_len), (trg_label, trg_len)) = (src_tuple, trg_tuple) # tf.concat用法 https://blog.csdn.net/qq_33431368/article/details/79429295 trg_input = tf.concat([[SOS_ID], trg_label[:-1]], axis=0) return ((src_input, src_len), (trg_input, trg_label, trg_len)) dataset = dataset.map(MakeTrgInput) # 随机打乱训练数据 dataset = dataset.shuffle(10000) # 规定填充后的输出的数据维度 padded_shapes = ( (tf.TensorShape([None]), # 源句子是长度未知的向量 tf.TensorShape([])), # 源句子长度是单个数字 (tf.TensorShape([None]), # 目标句子(解码器输入)是长度未知的向量 tf.TensorShape([None]), # 目标句子(解码器目标输出)是长度未知的向量 tf.TensorShape([])) # 目标句子长度(输出)是单个数字 ) # 调用padded_batch方法进行padding 和 batching操作 batched_dataset = dataset.padded_batch(batch_size, padded_shapes) return batched_dataset """ function: seq2seq模型 Parameters: Returns: """ class NMTModel(object): """ function: 模型初始化 Parameters: Returns: """ def __init__(self): # 定义编码器和解码器所使用的LSTM结构 self.enc_cell = tf.nn.rnn_cell.MultiRNNCell( [tf.nn.rnn_cell.LSTMCell(HIDDEN_SIZE) for _ in range(NUM_LAYERS)]) self.dec_cell = tf.nn.rnn_cell.MultiRNNCell( [tf.nn.rnn_cell.LSTMCell(HIDDEN_SIZE) for _ in range(NUM_LAYERS)]) # 为源语言和目标语言分别定义词向量 self.src_embedding = tf.get_variable('src_emb', [SRC_VOCAB_SIZE, HIDDEN_SIZE]) self.trg_embedding = tf.get_variable('trg_emb', [TRG_VOCAB_SIZE, HIDDEN_SIZE]) # 定义softmax层的变量 if SHARE_EMB_AND_SOFTMAX: self.softmax_weight = tf.transpose(self.trg_embedding) else: self.softmax_weight = tf.get_variable('weight', [HIDDEN_SIZE, TRG_VOCAB_SIZE]) self.softmax_bias = tf.get_variable('softmax_loss', [TRG_VOCAB_SIZE]) """ function: 在forward函数中定义模型的前向计算图 Parameters:   MakeSrcTrgDataset函数产生的五种张量如下(全部为张量) src_input: 编码器输入(源数据) src_size : 输入大小 trg_input:解码器输入(目标数据) trg_label:解码器输出(目标数据) trg_size: 输出大小 Returns: """ def forward(self, src_input, src_size, trg_input, trg_label, trg_size): batch_size = tf.shape(src_input)[0] # 将输入和输出单词转为词向量(rnn中输入数据都要转换成词向量) # 相当于input中的每个id对应的embedding中的向量转换 src_emb = tf.nn.embedding_lookup(self.src_embedding, src_input) trg_emb = tf.nn.embedding_lookup(self.trg_embedding, trg_input) # 在词向量上进行dropout src_emb = tf.nn.dropout(src_emb, KEEP_PROB) trg_emb = tf.nn.dropout(trg_emb, KEEP_PROB) # 使用dynamic_rnn构造编码器 # 编码器读取源句子每个位置的词向量,输出最后一步的隐藏状态enc_state # 因为编码器是一个双层LSTM,因此enc_state是一个包含两个LSTMStateTuple类的tuple, # 每个LSTMStateTuple对应编码器中一层的状态 # enc_outputs是顶层LSTM在每一步的输出,它的维度是[batch_size, max_time, HIDDEN_SIZE] # seq2seq模型中不需要用到enc_outputs,而attention模型会用到它 with tf.variable_scope('encoder'): enc_outputs, enc_state = tf.nn.dynamic_rnn(self.enc_cell, src_emb, src_size, dtype=tf.float32) # 使用dynamic_rnn构造解码器 # 解码器读取目标句子每个位置的词向量,输出的dec_outputs为每一步顶层LSTM的输出 # dec_outputs的维度是[batch_size, max_time, HIDDEN_SIZE] # initial_state=enc_state表示用编码器的输出来初始化第一步的隐藏状态 # 编码器最后编码结束最后的状态为解码器初始化的状态 with tf.variable_scope('decoder'): dec_outputs, _ = tf.nn.dynamic_rnn(self.dec_cell, trg_emb, trg_size, initial_state=enc_state) # 计算解码器每一步的log perplexity # 输出重新转换成shape为[,HIDDEN_SIZE] output = tf.reshape(dec_outputs, [-1, HIDDEN_SIZE]) # 计算解码器每一步的softmax概率值 logits = tf.matmul(output, self.softmax_weight) + self.softmax_bias # 交叉熵损失函数,算loss loss = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=tf.reshape(trg_label, [-1]), logits=logits) # 在计算平均损失时,需要将填充位置的权重设置为0,以避免无效位置的预测干扰模型的训练 label_weights = tf.sequence_mask(trg_size, maxlen=tf.shape(trg_label)[1], dtype=tf.float32) label_weights = tf.reshape(label_weights, [-1]) cost = tf.reduce_sum(loss * label_weights) cost_per_token = cost / tf.reduce_sum(label_weights) # 定义反向传播操作 trainable_variables = tf.trainable_variables() # 控制梯度大小,定义优化方法和训练步骤 # 算出每个需要更新的值的梯度,并对其进行控制 grads = tf.gradients(cost / tf.to_float(batch_size), trainable_variables) grads, _ = tf.clip_by_global_norm(grads, MAX_GRAD_NORM) # 利用梯度下降优化算法进行优化.学习率为1.0 optimizer = tf.train.GradientDescentOptimizer(learning_rate=1.0) # 相当于minimize的第二步,正常来讲所得到的list[grads,vars]由compute_gradients得到,返回的是执行对应变量的更新梯度操作的op train_op = optimizer.apply_gradients(zip(grads, trainable_variables)) return cost_per_token, train_op """ function: 使用给定的模型model上训练一个epoch,并返回全局步数,每训练200步便保存一个checkpoint Parameters: session : 会议 cost_op : 计算loss的操作op train_op: 训练的操作op saver:  保存model的类 step:   训练步数 Returns: """ def run_epoch(session, cost_op, train_op, saver, step): # 训练一个epoch # 重复训练步骤直至遍历完Dataset中所有数据 while True: try: # 运行train_op并计算cost_op的结果也就是损失值,训练数据在main()函数中以Dataset方式提供 cost, _ = session.run([cost_op, train_op]) # 步数为10的倍数进行打印 if step % 10 == 0: print('After %d steps, per token cost is %.3f' % (step, cost)) # 每200步保存一个checkpoint if step % 200 == 0: saver.save(session, CHECKPOINT_PATH, global_step=step) step += 1 except tf.errors.OutOfRangeError: break return step """ function: 主函数 Parameters: Returns: """ def main(): # 定义初始化函数 initializer = tf.random_uniform_initializer(-0.05, 0.05) # 定义训练用的循环神经网络模型 with tf.variable_scope('nmt_model', reuse=None, initializer=initializer): train_model = NMTModel() # 定义输入数据 data = MakeSrcTrgDataset(SRC_TRAIN_DATA, TRG_TRAIN_DATA, BATCH_SIZE) iterator = data.make_initializable_iterator() (src, src_size), (trg_input, trg_label, trg_size) = iterator.get_next() # 定义前向计算图,输入数据以张量形式提供给forward函数 cost_op, train_op = train_model.forward(src, src_size, trg_input, trg_label, trg_size) # 训练模型 # 保存模型 saver = tf.train.Saver() step = 0 with tf.Session() as sess: # 初始化全部变量 tf.global_variables_initializer().run() # 进行NUM_EPOCH轮数 for i in range(NUM_EPOCH): print('In iteration: %d' % (i + 1)) sess.run(iterator.initializer) step = run_epoch(sess, cost_op, train_op, saver, step) if __name__ == '__main__': main() ``` 问题如下,不知道怎么解决,谢谢! Traceback (most recent call last): File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call return fn(*args) File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: StringToNumberOp could not correctly convert string: This [[{{node StringToNumber}}]] [[{{node IteratorGetNext}}]] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:/Python37/untitled1/train_model.py", line 277, in <module> main() File "D:/Python37/untitled1/train_model.py", line 273, in main step = run_epoch(sess, cost_op, train_op, saver, step) File "D:/Python37/untitled1/train_model.py", line 231, in run_epoch cost, _ = session.run([cost_op, train_op]) File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 929, in run run_metadata_ptr) File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1328, in _do_run run_metadata) File "D:\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py", line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: StringToNumberOp could not correctly convert string: This [[{{node StringToNumber}}]] [[node IteratorGetNext (defined at D:/Python37/untitled1/train_model.py:259) ]]

使用tensorflow的API dataset遇到memoryerror

使用Tensorflow的API dataset的时候遇到了memoryerror,可是我是使用官方推荐的占位符的方法啊,我的系统是ubuntu 18.0.4,tensorflow 的版本是1.13.1,Python3.6,先上代码: ``` def main(_): if FLAGS.self_test: train_data, train_labels = fake_data(256) validation_data, validation_labels = fake_data(EVAL_BATCH_SIZE) test_data, test_labels = fake_data(EVAL_BATCH_SIZE) num_epochs = 1 else: stft_training, mfcc_training, labels_training = joblib.load(open(FLAGS.input, mode='rb')) stft_training = numpy.array(stft_training) mfcc_training = numpy.array(mfcc_training) labels_training = numpy.array(labels_training) stft_shape = stft_training.shape stft_shape = (None, stft_shape[1], stft_shape[2]) mfcc_shape = mfcc_training.shape mfcc_shape = (None, mfcc_shape[1], mfcc_shape[2]) labels_shape = labels_training.shape labels_shape = (None) stft_placeholder = tf.placeholder(stft_training.dtype, stft_shape) labels_placeholder = tf.placeholder(labels_training.dtype, labels_shape) mfcc_placeholder = tf.placeholder(mfcc_training.dtype, mfcc_shape) dataset_training = tf.data.Dataset.from_tensor_slices((stft_placeholder, mfcc_placeholder, labels_placeholder)) dataset_training = dataset_training .apply( tf.data.experimental.shuffle_and_repeat(len(stft_training), None)) dataset_training = dataset_training .batch(BATCH_SIZE) dataset_training = dataset_training .prefetch(1) iterator_training = dataset_training.make_initializable_iterator() next_element_training = iterator_training.get_next() num_epochs = NUM_EPOCHS train_size = labels_training.shape[0] stft = tf.placeholder( data_type(), shape=(BATCH_SIZE, IMAGE_HEIGHT, IMAGE_WEITH, NUM_CHANNELS)) mfcc = tf.placeholder( data_type(), shape=(BATCH_SIZE, IMAGE_HEIGHT, IMAGE_WEITH, NUM_CHANNELS)) labels = tf.placeholder(tf.int64, shape=(BATCH_SIZE,)) model = BRN(stft, mfcc) config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config=config) as sess: tf.global_variables_initializer().run() train_writer = tf.summary.FileWriter(log_dir + 'train', sess.graph) converter = tf.lite.TFLiteConverter.from_session(sess, [stft,mfcc], [logits]) tflite_model = converter.convert() open("BRN.tflite", "wb").write(tflite_model) print('Initialized!') sess.run(iterator_training.initializer, feed_dict={stft_placeholder:stft_training, mfcc_placeholder:stft_training, labels_placeholder:stft_training}) ``` 报错信息: ![图片说明](https://img-ask.csdn.net/upload/201907/21/1563699144_423650.png)

BERT模型训练报错:IndexError: list index out of range,求大佬指教!

![图片说明](https://img-ask.csdn.net/upload/202004/29/1588175660_746755.png) 运行结果: ``` C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) Traceback (most recent call last): File "D:/senti/code/Bert/run_classifier.py", line 1024, in <module> tf.app.run() File "C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "D:/senti/code/Bert/run_classifier.py", line 885, in main train_examples = processor.get_train_examples(FLAGS.data_dir) File "D:/senti/code/Bert/run_classifier.py", line 385, in get_train_examples self._read_tsv(os.path.join(data_dir, "train.tsv")), "train") File "D:/senti/code/Bert/run_classifier.py", line 408, in _create_examples text_a = tokenization.convert_to_unicode(line[1]) IndexError: list index out of range ```

monkeyrunner运行报错如下

181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last): File "E:\Appium\Tools\Android\Android-sdk\android-sdk-windows\tools\lib\Lib\encodings\__init__.py", line 31, in <module> import codecs File "E:\Appium\Tools\Android\Android-sdk\android-sdk-windows\tools\lib\Lib\codecs.py", line 16 except ImportError as why: ^ SyntaxError: mismatched input 'as' expecting COLON 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.ParserFacade.fixParseError(ParserFacade.java:92) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.ParserFacade.parse(ParserFacade.java:184) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.compileSource(imp.java:326) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.createFromSource(imp.java:348) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.loadFromSource(imp.java:581) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.find_module(imp.java:478) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.import_next(imp.java:718) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.import_first(imp.java:748) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.import_module_level(imp.java:837) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.importName(imp.java:917) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.ImportFunction.__call__(__builtin__.java:1220) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.__call__(PyObject.java:357) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.__builtin__.__import__(__builtin__.java:1173) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.importOne(imp.java:936) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at encodings$py.f$0(E:\Appium\Tools\Android\Android-sdk\android-sdk-windows\tools\lib\Lib\encodings\__init__.py:152) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at encodings$py.call_function(E:\Appium\Tools\Android\Android-sdk\android-sdk-windows\tools\lib\Lib\encodings\__init__.py) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyCode.call(PyCode.java:18) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.createFromCode(imp.java:391) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.createFromPyClass(imp.java:209) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.loadFromSource(imp.java:572) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.find_module(imp.java:478) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.import_next(imp.java:718) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.import_first(imp.java:739) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.imp.load(imp.java:631) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.codecs.import_encodings(codecs.java:109) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.codecs.registry_init(codecs.java:405) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.codecs.lookup(codecs.java:74) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.codecs.encode(codecs.java:192) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyString.str_encode(PyString.java:2458) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyString.encode(PyString.java:2449) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.GrammarActions.extractString(GrammarActions.java:472) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.GrammarActions.extractStrings(GrammarActions.java:428) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.atom(PythonParser.java:10896) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.power(PythonParser.java:10215) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.factor(PythonParser.java:10142) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.term(PythonParser.java:9696) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.arith_expr(PythonParser.java:9422) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.shift_expr(PythonParser.java:9149) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.and_expr(PythonParser.java:8982) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.xor_expr(PythonParser.java:8819) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.expr(PythonParser.java:8655) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.comparison(PythonParser.java:8201) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.not_test(PythonParser.java:8128) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.and_test(PythonParser.java:7920) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.or_test(PythonParser.java:7758) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.test(PythonParser.java:7618) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.testlist(PythonParser.java:12581) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.expr_stmt(PythonParser.java:3032) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.small_stmt(PythonParser.java:2584) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.simple_stmt(PythonParser.java:2433) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.stmt(PythonParser.java:2347) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.PythonParser.file_input(PythonParser.java:641) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.antlr.BaseParser.parseModule(BaseParser.java:78) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.CompileMode$3.dispatch(CompileMode.java:22) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.ParserFacade.parse(ParserFacade.java:152) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.ParserFacade.parse(ParserFacade.java:182) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.compile_flags(Py.java:1731) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.__builtin__.execfile_flags(__builtin__.java:514) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:225) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77) 181031 16:29:52.035:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)

基于bert的文本分类报错,求大佬指教

报错: ``` raise _exceptions.IllegalFlagValueError('%s: %s' % (message, str(e))) absl.flags._exceptions.IllegalFlagValueError: flag --data_dir=None: Flag --data_dir must have a value other than None. ``` data_dir的路径应该没有错,检查好多遍了

C# Winform 自动安装p12 证书 提示拒绝访问

代码: //添加个人证书 X509Certificate2 certificate = new X509Certificate2("C:\\test.p12","证书密码"); X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadWrite); store.Remove(certificate); //可省略 store.Add(certificate); store.Close(); store.Open(OpenFlags.ReadWrite); 这就话报错 错误提示: System.Security.Cryptography.CryptographicException: 拒绝访问。 在 System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags) 在 PcHealthDoctor.MainForm.MainForm_Load(Object sender, EventArgs e) 位置 D:\PcHealthDoctor\PcHealthDoctor\MainForm.cs:行号 208

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

CSDN:因博主近期注重写专栏文章(已超过150篇),订阅博主专栏人数在突增,近期很有可能提高专栏价格(已订阅的不受影响),提前声明,敬请理解!

CSDN:因博主近期注重写专栏文章(已超过150篇),订阅博主专栏人数在突增,近期很有可能提高专栏价格(已订阅的不受影响),提前声明,敬请理解! 目录 博客声明 大数据了解博主粉丝 博主的粉丝群体画像 粉丝群体性别比例、年龄分布 粉丝群体学历分布、职业分布、行业分布 国内、国外粉丝群体地域分布 博主的近期访问每日增量、粉丝每日增量 博客声明 因近期博主写专栏的文章越来越多,也越来越精细,逐步优化文章。因此,最近一段时间,订阅博主专栏的人数增长也非常快,并且专栏价

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

培训班出来的人后来都怎么样了?(二)

接着上回说,培训班学习生涯结束了。后面每天就是无休止的背面试题,不是没有头脑的背,培训公司还是有方法的,现在回想当时背的面试题好像都用上了,也被问到了。回头找找面试题,当时都是打印下来天天看,天天背。 不理解呢也要背,面试造飞机,上班拧螺丝。班里的同学开始四处投简历面试了,很快就有面试成功的,刚开始一个,然后越来越多。不知道是什么原因,尝到胜利果实的童鞋,不满足于自己通过的公司,嫌薪水要少了,选择...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

工作八年,月薪60K,裸辞两个月,投简历投到怀疑人生!

近日,有网友在某职场社交平台吐槽,自己裸辞两个月了,但是找工作却让自己的心态都要崩溃了,全部无果,不是已查看无回音,就是已查看不符合。 “工作八年,两年一跳,裸辞两个月了,之前月薪60K,最近找工作找的心态崩了!所有招聘工具都用了,全部无果,不是已查看无回音,就是已查看不符合。进头条,滴滴之类的大厂很难吗???!!!投简历投的开始怀疑人生了!希望 可以收到大厂offer” 先来看看网...

97年世界黑客编程大赛冠军作品(大小仅为16KB),惊艳世界的编程巨作

这是世界编程大赛第一名作品(97年Mekka ’97 4K Intro比赛)汇编语言所写。 整个文件只有4095个字节, 大小仅仅为16KB! 不仅实现了3D动画的效果!还有一段震撼人心的背景音乐!!! 内容无法以言语形容,实在太强大! 下面是代码,具体操作看最后! @echo off more +1 %~s0|debug e100 33 f6 bf 0 20 b5 10 f3 a5...

不要再到处使用 === 了

我们知道现在的开发人员都使用 === 来代替 ==,为什么呢?我在网上看到的大多数教程都认为,要预测 JavaScript 强制转换是如何工作这太复杂了,因此建议总是使用===。这些都...

什么是a站、b站、c站、d站、e站、f站、g站、h站、i站、j站、k站、l站、m站、n站?00后的世界我不懂!

A站 AcFun弹幕视频网,简称“A站”,成立于2007年6月,取意于Anime Comic Fun,是中国大陆第一家弹幕视频网站。A站以视频为载体,逐步发展出基于原生内容二次创作的完整生态,拥有高质量互动弹幕,是中国弹幕文化的发源地;拥有大量超粘性的用户群体,产生输出了金坷垃、鬼畜全明星、我的滑板鞋、小苹果等大量网络流行文化,也是中国二次元文化的发源地。 B站 全称“哔哩哔哩(bilibili...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

MySQL性能优化(五):为什么查询速度这么慢

前期回顾: MySQL性能优化(一):MySQL架构与核心问题 MySQL性能优化(二):选择优化的数据类型 MySQL性能优化(三):深入理解索引的这点事 MySQL性能优化(四):如何高效正确的使用索引 前面章节我们介绍了如何选择优化的数据类型、如何高效的使用索引,这些对于高性能的MySQL来说是必不可少的。但这些还完全不够,还需要合理的设计查询。如果查询写的很糟糕,即使表结构再合理、索引再...

用了这个 IDE 插件,5分钟解决前后端联调!

点击上方蓝色“程序猿DD”,选择“设为星标”回复“资源”获取独家整理的学习资料!作者 |李海庆我是一个 Web 开发前端工程师,受到疫情影响,今天是我在家办公的第78天。开发了两周,...

大厂的 404 页面都长啥样?最后一个笑了...

每天浏览各大网站,难免会碰到404页面啊。你注意过404页面么?猿妹搜罗来了下面这些知名网站的404页面,以供大家欣赏,看看哪个网站更有创意: 正在上传…重新上传取消 腾讯 正在上传…重新上传取消 网易 淘宝 百度 新浪微博 正在上传…重新上传取消 新浪 京东 优酷 腾讯视频 搜...

【高并发】高并发秒杀系统架构解密,不是所有的秒杀都是秒杀!

网上很多的文章和帖子中在介绍秒杀系统时,说是在下单时使用异步削峰来进行一些限流操作,那都是在扯淡! 因为下单操作在整个秒杀系统的流程中属于比较靠后的操作了,限流操作一定要前置处理,在秒杀业务后面的流程中做限流操作是没啥卵用的。

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

Java14 新特性解读

Java14 已于 2020 年 3 月 17 号发布,官方特性解读在这里:https://openjdk.java.net/projects/jdk/14/以下是个人对于特性的中文式...

爬虫(101)爬点重口味的

小弟最近在学校无聊的很哪,浏览网页突然看到一张图片,都快流鼻血。。。然后小弟冥思苦想,得干一点有趣的事情python 爬虫库安装https://s.taobao.com/api?_ks...

疫情后北上广深租房价格跌了吗? | Alfred数据室

去年3月份我们发布了《北上广深租房图鉴》(点击阅读),细数了北上广深租房的各种因素对租房价格的影响。一年过去了,在面临新冠疫情的后续影响、城市尚未完全恢复正常运转、学校还没开学等情况下...

面试官给我挖坑:a[i][j] 和 a[j][i] 有什么区别?

点击上方“朱小厮的博客”,选择“设为星标”后台回复&#34;1024&#34;领取公众号专属资料本文以一个简单的程序开头——数组赋值:int LEN = 10000; int[][] ...

又一起程序员被抓事件

就在昨天互联网又发生一起让人心酸的程序员犯罪事件,著名的百度不限速下载软件 Pandownload PC 版作者被警方抓获。案件大致是这样的:软件的作者不仅非法盗取用户数据,还在QQ群进...

应聘3万的职位,有必要这么刁难我么。。。沙雕。。。

又一次被面试官带到坑里面了。面试官:springmvc用过么?我:用过啊,经常用呢面试官:springmvc中为什么需要用父子容器?我:嗯。。。没听明白你说的什么。面试官:就是contr...

太狠了,疫情期间面试,一个问题砍了我5000!

疫情期间找工作确实有点难度,想拿到满意的薪资,确实要点实力啊!面试官:Spring中的@Value用过么,介绍一下我:@Value可以标注在字段上面,可以将外部配置文件中的数据,比如可以...

Intellij IDEA 美化指南

经常有人问我,你的 IDEA 配色哪里搞的,我会告诉他我自己改的。作为生产力工具,不但要顺手而且更要顺眼。这样才能快乐编码,甚至降低 BUG 率。上次分享了一些 IDEA 有用的插件,反...

【相亲】96年程序员小哥第一次相亲,还没开始就结束了

颜值有点高,条件有点好

太厉害了,终于有人能把TCP/IP 协议讲的明明白白了

一图看完本文 一、 计算机网络体系结构分层 计算机网络体系结构分层 计算机网络体系结构分层 不难看出,TCP/IP 与 OSI 在分层模块上稍有区别。OSI 参考模型注重“通信协议必要的功能是什么”,而 TCP/IP 则更强调“在计算机上实现协议应该开发哪种程序”。 二、 TCP/IP 基础 1. TCP/IP 的具体含义 从字面意义上讲,有人可能会认为...

腾讯面试题: 百度搜索为什么那么快?

我还记得去年面腾讯时,面试官最后一个问题是:百度/google的搜索为什么那么快? 这个问题我懵了,我从来没想过,搜素引擎的原理是什么 然后我回答:百度爬取了各个网站的信息,然后进行排序,当输入关键词的时候进行文档比对……巴拉巴拉 面试官:这不是我想要的答案 我内心 这个问题我一直耿耿于怀,终于今天,我把他写出来,以后再问,我直接把这篇文章甩给他!!! 两个字:倒排,将贯穿整篇文章,也是面试官...

相关热词 c#树形选择 c#中类图的使用方法 c# 传参 调用exe c# 怎么定义方法 c# 修改本地时间 c#前台怎么读取资源文件 c# xml转list c#实现框选截图 m*m乘法表c# c# 乘法99表
立即提问