tensorflow环境下只要import keras 就会出现python已停止运行?

python小白在写代码的时候发现只要import keras就会出现python停止运行的情况,目前tensorflow版本1.2.1,keras版本2.1.1,防火墙关了也还是这样,具体代码和问题信息如下,请大神赐教。

# -*- coding: utf-8 -*-
import numpy as np
from scipy.io import loadmat, savemat
from keras.utils import np_utils


 问题事件名称:    BEX64
  应用程序名:  pythonw.exe
  应用程序版本:   3.6.2150.1013
  应用程序时间戳:    5970e8ca
  故障模块名称:   StackHash_1dc2
  故障模块版本:   0.0.0.0
  故障模块时间戳:    00000000
  异常偏移: 0000000000000000
  异常代码: c0000005
  异常数据: 0000000000000008
  OS 版本:    6.1.7601.2.1.0.256.1
  区域设置 ID:  2052
  其他信息 1:   1dc2
  其他信息 2:   1dc22fb1de37d348f27e54dbb5278e7d
  其他信息 3:   eae3
  其他信息 4:   eae36a4b5ffb27c9d33117f4125a75c2


u012977885
ltxz 解决了吗?我现在也是,只要运行model中的函数就报错
4 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Tensorflow代码转到Keras

我现在有Tensortflow的代码和结构图如下,这是AC-GAN中生成器的部分,我用原生tf是可以跑通的,但当我想转到Keras中实现却很头疼。 ``` def batch_norm(inputs, is_training=is_training, decay=0.9): return tf.contrib.layers.batch_norm(inputs, is_training=is_training, decay=decay) # 构建残差块 def g_block(inputs): h0 = tf.nn.relu(batch_norm(conv2d(inputs, 3, 64, 1, use_bias=False))) h0 = batch_norm(conv2d(h0, 3, 64, 1, use_bias=False)) h0 = tf.add(h0, inputs) return h0 # 生成器 # batch_size = 32 # z : shape(32, 128) # label : shape(32, 34) def generator(z, label): with tf.variable_scope('generator', reuse=None): d = 16 z = tf.concat([z, label], axis=1) h0 = tf.layers.dense(z, units=d * d * 64) h0 = tf.reshape(h0, shape=[-1, d, d, 64]) h0 = tf.nn.relu(batch_norm(h0)) shortcut = h0 for i in range(16): h0 = g_block(h0) h0 = tf.nn.relu(batch_norm(h0)) h0 = tf.add(h0, shortcut) for i in range(3): h0 = conv2d(h0, 3, 256, 1, use_bias=False) h0 = tf.depth_to_space(h0, 2) h0 = tf.nn.relu(batch_norm(h0)) h0 = tf.layers.conv2d(h0, kernel_size=9, filters=3, strides=1, padding='same', activation=tf.nn.tanh, name='g', use_bias=True) return h0 ``` ![生成器结构图](https://img-ask.csdn.net/upload/201910/29/1572278934_997142.png) 在Keras中都是先构建Model,在Model中不断的加层 但上面的代码却是中间包含着新旧数据的计算,比如 ``` .... shortcut = h0 .... h0 = tf.add(h0, shortcut) ``` 难不成我还要构建另外一个model作为中间输出吗? 大佬们帮帮忙解释下,或者能不能给出翻译到Keras中应该怎么写

使用Keras找不到tensorflow

程序代码 #-*- coding: utf-8 -*- #使用神经网络算法预测销量高低 import pandas as pd #参数初始化 inputfile = 'D:/python/chapter5/demo/data/sales_data.xls' data = pd.read_excel(inputfile, index_col = u'序号') #导入数据 #数据是类别标签,要将它转换为数据 #用1来表示“好”、“是”、“高”这三个属性,用0来表示“坏”、“否”、“低” data[data == u'好'] = 1 data[data == u'是'] = 1 data[data == u'高'] = 1 data[data != 1] = 0 x = data.iloc[:,:3].as_matrix().astype(int) y = data.iloc[:,3].as_matrix().astype(int) from keras.models import Sequential from keras.layers.core import Dense, Activation model = Sequential() #建立模型 model.add(Dense(input_dim = 3, output_dim = 10)) model.add(Activation('relu')) #用relu函数作为激活函数,能够大幅提供准确度 model.add(Dense(input_dim = 10, output_dim = 1)) model.add(Activation('sigmoid')) #由于是0-1输出,用sigmoid函数作为激活函数 model.compile(loss = 'binary_crossentropy', optimizer = 'adam', class_mode = 'binary') #编译模型。由于我们做的是二元分类,所以我们指定损失函数为binary_crossentropy,以及模式为binary #另外常见的损失函数还有mean_squared_error、categorical_crossentropy等,请阅读帮助文件。 #求解方法我们指定用adam,还有sgd、rmsprop等可选 model.fit(x, y, nb_epoch = 1000, batch_size = 10) #训练模型,学习一千次 yp = model.predict_classes(x).reshape(len(y)) #分类预测 from cm_plot import * #导入自行编写的混淆矩阵可视化函数 cm_plot(y,yp).show() #显示混淆矩阵可视化结果 错误提示 Using TensorFlow backend. Traceback (most recent call last): File "D:\python\chapter5\demo\code\5-3_neural_network.py", line 19, in <module> from keras.models import Sequential File "C:\Python27\lib\site-packages\keras\__init__.py", line 3, in <module> from . import utils File "C:\Python27\lib\site-packages\keras\utils\__init__.py", line 6, in <module> from . import conv_utils File "C:\Python27\lib\site-packages\keras\utils\conv_utils.py", line 3, in <module> from .. import backend as K File "C:\Python27\lib\site-packages\keras\backend\__init__.py", line 83, in <module> from .tensorflow_backend import * File "C:\Python27\lib\site-packages\keras\backend\tensorflow_backend.py", line 1, in <module> import tensorflow as tf ImportError: No module named tensorflow

TensorFlow的Keras如何使用Dataset作为数据输入?

当我把dataset作为输入数据是总会报出如下错误,尽管我已经在数据解析那里reshape了图片大小为(512,512,1),请问该如何修改? ``` ValueError: Error when checking input: expected conv2d_input to have 4 dimensions, but got array with shape (None, 1) ``` **图片大小定义** ``` import tensorflow as tf from tensorflow import keras IMG_HEIGHT = 512 IMG_WIDTH = 512 IMG_CHANNELS = 1 IMG_PIXELS = IMG_CHANNELS * IMG_HEIGHT * IMG_WIDTH ``` **解析函数** ``` def parser(record): features = tf.parse_single_example(record, features={ 'image_raw': tf.FixedLenFeature([], tf.string), 'label': tf.FixedLenFeature([23], tf.int64) }) image = tf.decode_raw(features['image_raw'], tf.uint8) label = tf.cast(features['label'], tf.int32) image.set_shape([IMG_PIXELS]) image = tf.reshape(image, [IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS]) image = tf.cast(image, tf.float32) return image, label ``` **模型构建** ``` dataset = tf.data.TFRecordDataset([TFRECORD_PATH]) dataset.map(parser) dataset = dataset.repeat(10*10).batch(10) model = keras.Sequential([ keras.layers.Conv2D(filters=32, kernel_size=(5, 5), padding='same', activation='relu', input_shape=(512, 512, 1)), keras.layers.MaxPool2D(pool_size=(2, 2)), keras.layers.Dropout(0.25), keras.layers.Conv2D(filters=64, kernel_size=(3, 3), padding='same', activation='relu'), keras.layers.MaxPool2D(pool_size=(2, 2)), keras.layers.Dropout(0.25), keras.layers.Flatten(), keras.layers.Dense(128, activation='relu'), keras.layers.Dropout(0.25), keras.layers.Dense(23, activation='softmax') ]) model.compile(optimizer=keras.optimizers.Adam(), loss=keras.losses.sparse_categorical_crossentropy, metrics=[tf.keras.metrics.categorical_accuracy]) model.fit(dataset.make_one_shot_iterator(), epochs=10, steps_per_epoch=10) ```

ubuntu下调用keras报错:No module named 'error'

cuda9.0和TensorFlow1.8.0已安装 import tensorflow也没有问题,就是再import keras出错,求大神解答! 报错如下: Using TensorFlow backend. Traceback (most recent call last): File "/home/zhangzhiyang/PycharmProjects/tensorflow1/test_keras.py", line 2, in <module> import keras File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module> from . import utils File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/utils/__init__.py", line 26, in <module> from .multi_gpu_utils import multi_gpu_model File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/utils/multi_gpu_utils.py", line 7, in <module> from ..layers.merge import concatenate File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/layers/__init__.py", line 4, in <module> from ..engine.base_layer import Layer File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/__init__.py", line 7, in <module> from .network import get_source_inputs File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/network.py", line 9, in <module> import yaml File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/yaml/__init__.py", line 2, in <module> from error import * ModuleNotFoundError: No module named 'error' 我的版本:tensorflow1.8.0,cuda9.0,cuDNN7,anaconda3,python3.6.5 我的tensorflow和keras安装路径均为anaconda3/envs/tensorflow/lib/python3.6/site-packages 我的.bashrc文件如下: export PATH="/home/zhangzhiyang/anaconda3/bin:$PATH" export LD_LIBRARY_PATH="/home/zhangzhiyang/newdisk/cuda-9.0/lib64:$LD_LIBRARY_PATH" export PATH="/home/zhangzhiyang/newdisk/cuda-9.0/bin:$PATH" export CUDA_HOME=$CUDA_HOME:"/home/zhangzhiyang/newdisk/cuda-9.0" 个人推测可能是python版本的问题,但不知如何解决,我第一次pip Keras未指定安装路径,结果keras安装在了python2.7下,这次我指定了路径为python3.6/site_packages,但是报了如上错误,是否keras不支持python3? 求大神解答!

python3.7中的tensorflow2.0模块没有的问题。

小白刚做手写字识别,遇到tensorflow导入模块的一些问题,模块ModuleNotFoundError: No module named 'tensorflow.examples.tutorials'不会解决。 import keras # 导入Keras import numpy as np from keras.datasets import mnist # 从keras中导入mnist数据集 from keras.models import Sequential # 导入序贯模型 from keras.layers import Dense # 导入全连接层 from keras.optimizers import SGD # 导入优化函数 from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data", one_hot = True) ![图片说明](https://img-ask.csdn.net/upload/201911/17/1573957701_315782.png) 在网上找了好久,也不怎么懂,能告诉我详实点的解决办法。

tensorflow安装后不能import

我安装的tensorflow是这个 pip install -i http://pypi.douban.com/simple/ tensorflow-gpu==1.13.1 CUDA是10.1,python=3.7 但是import tensorflow as tf 时报错 ![截图](https://img-ask.csdn.net/upload/201911/01/1572614573_625855.png)

C++调用python 控制台可以成功,mfc失败,python脚本里依赖tensorflow

x64控制台与MFC控制台同样的配置; 关键C++代码如下: ``` #define PY_modePath L"E:\\Anaconda\\envs\\asr\\" ``` Py_SetPythonHome(PY_modePath); pModule = PyImport_ImportModule(aasr.c_str());//mfc是null 控制台是OK的 python代码如下: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- ``` """ @author: sly """ import platform as plat import os import time from general_function.file_wav import * from general_function.file_dict import * from general_function.gen_func import * import numpy as np import random from keras.models import Sequential, Model from keras.layers import Dense, Dropout, Input, Reshape, BatchNormalization # , Flatten from keras.layers import Lambda, TimeDistributed, Activation,Conv2D, MaxPooling2D #, Merge from keras import backend as K from keras.optimizers import SGD, Adadelta, Adam ``` ``` 路径检查多边没有问题. 对边了加载脚本时C++输出:

如何解决cannot import name 'dense_features' from 'tensorflow.python.feature_column'

出现了cannot import name 'dense_features' from 'tensorflow.python.feature_column'的问题,tensorflow是1.14.0版本,尝试过重新安装,无法解决,安装的其他package如下 ![图片说明](https://img-ask.csdn.net/upload/201909/24/1569296426_853190.png)

TensorFlow不能导入python的问题

Python版本2.7.13.下好tensorflow之后Import tensorflow as tf 失败了!![图片说明](https://img-ask.csdn.net/upload/201707/14/1499994613_742213.png)求大神解答一下啊!

Python Tensorflow中dense问题

tf.layers.dense中units的参数设定依据什么规则?是维数越大越精确吗?刚刚开始学,希望能细讲下谢谢

关于Colab上Keras模型转TPU模型的问题

使用TPU加速训练,将Keras模型转TPU模型时报错,如图![图片说明](https://img-ask.csdn.net/upload/202001/14/1578998736_238721.png) 关键代码如下 引用库: ``` %tensorflow_version 1.x import json import os import numpy as np import tensorflow as tf from tensorflow.python.keras.applications import resnet from tensorflow.python.keras import callbacks from tensorflow.python.keras.preprocessing.image import ImageDataGenerator import matplotlib.pyplot as plt ``` 转换TPU模型代码如下 ``` # This address identifies the TPU we'll use when configuring TensorFlow. TPU_WORKER = 'grpc://' + os.environ['COLAB_TPU_ADDR'] tf.logging.set_verbosity(tf.logging.INFO) self.model = tf.contrib.tpu.keras_to_tpu_model(self.model, strategy=tf.contrib.tpu.TPUDistributionStrategy(tf.contrib.cluster_resolver.TPUClusterResolver(TPU_WORKER))) self.model = resnet50.ResNet50(weights=None, input_shape=dataset.input_shape, classes=num_classes) ```

python keras sequential输入

python keras sequential 以Convolution1D作为第一层,输入的数据应该以怎样的形式? ![图片说明](https://img-ask.csdn.net/upload/201611/13/1479043537_386017.png) ![图片说明](https://img-ask.csdn.net/upload/201611/13/1479043555_758273.png) 刚开始接触,求老师能指点一下。

cmd显示tensorflow为1.14.0版本。anaconda显示1.2.0版本

``` python import tensorflow as tf tf.__version__ ``` 显示tensorflow为1.14.0版本。 但是anaconda中tensorflow环境显示其为1.2.0版本,是怎么回事?

关于keras框架的问题?????

Traceback (most recent call last): File "F:/python3.5/projects/untitled1/CNN/MN/test2.py", line 11, in <module> from keras.models import Sequential File "F:\python3.5\lib\site-packages\keras\__init__.py", line 3, in <module> from . import utils File "F:\python3.5\lib\site-packages\keras\utils\__init__.py", line 6, in <module> from . import conv_utils File "F:\python3.5\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module> from .. import backend as K File "F:\python3.5\lib\site-packages\keras\backend\__init__.py", line 72, in <module> assert _backend in {'theano', 'tensorflow', 'cntk'} AssertionError 为什么kears出现这种错误 后端的tensorflow也配置了 求大神解答一下

jupyter notebook 进行impor keras时出现更重问题,解决一个出现一个,有谁知道怎么回事么?

import keras时 总是出现: cannot import name 'xx' from 'xxx' AttributeError: module 'tensorflow' has no attribute 'xxxx' xxxxxx 'module' object has no attribute 'xxxxx' 尝试重装,更新都不行。。

求问大佬装TensorFlow出现这样的情况是怎么办呀

(TF2.1) C:\Users\lenovo>pip install tensorflow==2.1 Requirement already satisfied: tensorflow==2.1 in f:\anaconda3\envs\tf2.1\lib\site-packages (2.1.0) Requirement already satisfied: termcolor>=1.1.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.1.0) Requirement already satisfied: protobuf>=3.8.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (3.11.3) Requirement already satisfied: absl-py>=0.7.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (0.9.0) Requirement already satisfied: opt-einsum>=2.3.2 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (3.2.1) Requirement already satisfied: google-pasta>=0.1.6 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (0.2.0) Requirement already satisfied: wheel>=0.26; python_version >= "3" in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (0.34.2) Requirement already satisfied: wrapt>=1.11.1 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.12.1) Requirement already satisfied: gast==0.2.2 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (0.2.2) Requirement already satisfied: six>=1.12.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.14.0) Requirement already satisfied: numpy<2.0,>=1.16.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.18.4) Requirement already satisfied: tensorboard<2.2.0,>=2.1.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (2.1.1) Requirement already satisfied: tensorflow-estimator<2.2.0,>=2.1.0rc0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (2.1.0) Requirement already satisfied: grpcio>=1.8.6 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.28.1) Requirement already satisfied: astor>=0.6.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (0.8.1) Requirement already satisfied: scipy==1.4.1; python_version >= "3" in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.4.1) Requirement already satisfied: keras-applications>=1.0.8 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.0.8) Requirement already satisfied: keras-preprocessing>=1.1.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorflow==2.1) (1.1.0) Requirement already satisfied: setuptools in f:\anaconda3\envs\tf2.1\lib\site-packages (from protobuf>=3.8.0->tensorflow==2.1) (46.1.3.post20200330) Requirement already satisfied: markdown>=2.6.8 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (3.2.1) Requirement already satisfied: google-auth<2,>=1.6.3 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (1.14.1) Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (0.4.1) Requirement already satisfied: werkzeug>=0.11.15 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (1.0.1) Requirement already satisfied: requests<3,>=2.21.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (2.23.0) Requirement already satisfied: h5py in f:\anaconda3\envs\tf2.1\lib\site-packages (from keras-applications>=1.0.8->tensorflow==2.1) (2.10.0) Requirement already satisfied: pyasn1-modules>=0.2.1 in f:\anaconda3\envs\tf2.1\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (0.2.8) Requirement already satisfied: rsa<4.1,>=3.1.4 in f:\anaconda3\envs\tf2.1\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (4.0) Requirement already satisfied: cachetools<5.0,>=2.0.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (4.1.0) Requirement already satisfied: requests-oauthlib>=0.7.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (1.3.0) Requirement already satisfied: chardet<4,>=3.0.2 in f:\anaconda3\envs\tf2.1\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (3.0.4) Requirement already satisfied: idna<3,>=2.5 in f:\anaconda3\envs\tf2.1\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (2.9) Requirement already satisfied: certifi>=2017.4.17 in f:\anaconda3\envs\tf2.1\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (2020.4.5.1) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in f:\anaconda3\envs\tf2.1\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (1.25.9) Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in f:\anaconda3\envs\tf2.1\lib\site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (0.4.8) Requirement already satisfied: oauthlib>=3.0.0 in f:\anaconda3\envs\tf2.1\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.2.0,>=2.1.0->tensorflow==2.1) (3.1.0) (TF2.1) C:\Users\lenovo>python Python 3.7.7 (default, Apr 15 2020, 05:09:04) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf Traceback (most recent call last): File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "F:\anaconda3\envs\TF2.1\lib\imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "F:\anaconda3\envs\TF2.1\lib\imp.py", line 342, in load_dynamic return _load(spec) ImportError: DLL load failed: 找不到指定的模块。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow\__init__.py", line 101, in <module> from tensorflow_core import * File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module> from tensorflow.python.tools import module_util as _module_util File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__ module = self._load() File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow\__init__.py", line 44, in _load module = _importlib.import_module(self.__name__) File "F:\anaconda3\envs\TF2.1\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "F:\anaconda3\envs\TF2.1\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "F:\anaconda3\envs\TF2.1\lib\imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "F:\anaconda3\envs\TF2.1\lib\imp.py", line 342, in load_dynamic return _load(spec) ImportError: DLL load failed: 找不到指定的模块。 Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/errors for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.

使用Tensorflow 1.5进行非法指令(核心转储)

<div class="post-text" itemprop="text"> <p>I have a python script for running a tensorflow model, and I need to run this script from a PHP file (for complicated reasons) using the PHP <code>shell_exec</code> function. When I run the python file with the following code:</p> <pre><code>$command = 'cd testModels/crosswalkPredict &amp;&amp; . activate keras &amp;&amp; python test_script.py'; $output = shell_exec($command); </code></pre> <p>I get the following error: <code>Illegal instruction (core dumped)</code></p> <p>I read that the issue typcally occurs when the CPU doesn't support instructions that are present in newer versions of Tensorflow. So I downgraded to Tensorflow 1.5.</p> <p>However, this error does not occur when I run <code>cd testModels/crosswalkPredict &amp;&amp; . activate keras &amp;&amp; python test_script.py</code> directly from the terminal; it only occurs when I run it from within the PHP <code>shell_exec</code> function. </p> <p>I have gone as far as to try the python script with only the following lines:</p> <pre><code>import tensorflow print('Hello!') </code></pre> <p>It still gives the same error, so I know the issue occurs when all I'm doing is importing tensorflow and running the script with <code>shell_exec</code>.</p> <p>What could be the problem?</p> </div>

运行tensorflow时出现tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed这个错误

运行tensorflow时出现tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed这个错误,查了一下说是gpu被占用了,从下面这里开始出问题的: ``` 2019-10-17 09:28:49.495166: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6382 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1) (60000, 28, 28) (60000, 10) 2019-10-17 09:28:51.275415: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cublas64_100.dll'; dlerror: cublas64_100.dll not found ``` ![图片说明](https://img-ask.csdn.net/upload/201910/17/1571277238_292620.png) 最后显示的问题: ![图片说明](https://img-ask.csdn.net/upload/201910/17/1571277311_655722.png) 试了一下网上的方法,比如加代码: ``` gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) ``` 但最后提示: ![图片说明](https://img-ask.csdn.net/upload/201910/17/1571277460_72752.png) 现在不知道要怎么解决了。新手想试下简单的数字识别,步骤也是按教程一步步来的,可能用的版本和教程不一样,我用的是刚下的:2.0tensorflow和以下: ![图片说明](https://img-ask.csdn.net/upload/201910/17/1571277627_439100.png) 不知道会不会有版本问题,现在紧急求助各位大佬,还有没有其它可以尝试的方法。测试程序加法运算可以执行,数字识别图片运行的时候我看了下,GPU最大占有率才0.2%,下面是完整数字图片识别代码: ``` import os import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers, optimizers, datasets os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' #gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.2) #sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) (x, y), (x_val, y_val) = datasets.mnist.load_data() x = tf.convert_to_tensor(x, dtype=tf.float32) / 255. y = tf.convert_to_tensor(y, dtype=tf.int32) y = tf.one_hot(y, depth=10) print(x.shape, y.shape) train_dataset = tf.data.Dataset.from_tensor_slices((x, y)) train_dataset = train_dataset.batch(200) model = keras.Sequential([ layers.Dense(512, activation='relu'), layers.Dense(256, activation='relu'), layers.Dense(10)]) optimizer = optimizers.SGD(learning_rate=0.001) def train_epoch(epoch): # Step4.loop for step, (x, y) in enumerate(train_dataset): with tf.GradientTape() as tape: # [b, 28, 28] => [b, 784] x = tf.reshape(x, (-1, 28 * 28)) # Step1. compute output # [b, 784] => [b, 10] out = model(x) # Step2. compute loss loss = tf.reduce_sum(tf.square(out - y)) / x.shape[0] # Step3. optimize and update w1, w2, w3, b1, b2, b3 grads = tape.gradient(loss, model.trainable_variables) # w' = w - lr * grad optimizer.apply_gradients(zip(grads, model.trainable_variables)) if step % 100 == 0: print(epoch, step, 'loss:', loss.numpy()) def train(): for epoch in range(30): train_epoch(epoch) if __name__ == '__main__': train() ``` 希望能有人给下建议或解决方法,拜谢!

python3下安装tensorflow,感觉安装成功了可是总是有奇怪的东西跑出来?

已安装python3.6,现在安装tensorflow,下好安装包,放在python的scripts文件夹中。 在cmd中输入pip install tensorflow回车(尝试了好几次)。出现下面的数据: Microsoft Windows [版本 10.0.17134.285] (c) 2018 Microsoft Corporation。保留所有权利。 C:\Users\lenovo>pip install tensorflow Requirement already satisfied: tensorflow in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages Requirement already satisfied: numpy>=1.13.3 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: tensorboard<1.12.0,>=1.11.0 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: termcolor>=1.1.0 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: six>=1.10.0 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: astor>=0.6.0 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: grpcio>=1.8.6 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: protobuf>=3.6.0 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: setuptools<=39.1.0 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: wheel>=0.26 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: absl-py>=0.1.6 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: keras-preprocessing>=1.0.3 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: keras-applications>=1.0.5 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: gast>=0.2.0 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) Requirement already satisfied: markdown>=2.6.8 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<1.12.0,>=1.11.0->tensorflow) Requirement already satisfied: werkzeug>=0.11.10 in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<1.12.0,>=1.11.0->tensorflow) Requirement already satisfied: h5py in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages (from keras-applications>=1.0.5->tensorflow) You are using pip version 9.0.1, however version 18.0 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. C:\Users\lenovo> 我看出现Requirement already satisfied: tensorflow in c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages 不是就是安装成功了吗? 可是我在调用的时候又出现了这个: =================== RESTART: D:\python-files\keras\num.py =================== Using TensorFlow backend. Traceback (most recent call last): File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "C:\Users\lenovo\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, in load_dynamic return _load(spec) ImportError: DLL load failed: 动态链接库(DLL)初始化例程失败。 反正就是又失败了。 所以我这个tensorflow是安装成功了还是失败了?为什么会这样嘞?

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

ArrayList源码分析(入门篇)

ArrayList源码分析 前言: 写这篇博客的主要原因是,在我上一次参加千牵科技Java实习生面试时,有被面试官问到ArrayList为什么查找的速度较快,插入和删除的速度较慢?当时我回答得不好,很大的一部分原因是因为我没有阅读过ArrayList源码,虽然最后收到Offer了,但我拒绝了,打算寒假学得再深入些再广泛些,下学期开学后再去投递其他更好的公司。为了更加深入理解ArrayList,也为

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

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

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

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

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

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

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

玩转springboot启动banner定义所得

最近接手了一个springboot项目,不是不熟悉这个框架,启动时打印的信息吸引了我。 这不是我熟悉的常用springboot的打印信息啊,我打开自己的项目: 还真是的,不用默认的感觉也挺高大上的。一时兴起,就去研究了一下源代码,还正是有些收获,稍后我会总结一下。正常情况下做为一个老程序员,是不会对这种小儿科感兴趣的,不就是一个控制台打印嘛。哈哈! 于是出于最初的好奇,研究了项目的源代码。看到

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

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

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

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

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

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

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

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

立即提问
相关内容推荐