tensorflow

File system scheme '[local]' not implemented in Google Colab TPU

。_饼干妹妹 提交于 2021-01-02 19:13:11
问题 I am using TPU runtime in Google Colab, but having problems in reading files (not sure). I initialized TPU using: import tensorflow as tf import os import tensorflow_datasets as tfds resolver = tf.distribute.cluster_resolver.TPUClusterResolver(tpu='grpc://' + os.environ['COLAB_TPU_ADDR']) tf.config.experimental_connect_to_cluster(resolver) # This is the TPU initialization code that has to be at the beginning. tf.tpu.experimental.initialize_tpu_system(resolver) print("All devices: ", tf.config

零基础的他是这样规划Python学习路线的!

懵懂的女人 提交于 2021-01-02 12:08:56
入门Python学习难吗?怎样规划学习路线?Python是一种跨平台的计算机程序设计语言。Python现在在各个邻域都有十分广泛的应用,在近几年的上升趋势十分明显,未来的发展前景也十分广阔。现在就有许多小伙伴想要去学习Python编程语言,那么Python学习起来难吗,应该怎样去规划关于它的学习路线呢,下面我们就一起了解了解吧。  其实Python语言上手还比较容易、它功能强大、语法简单,相对于其他来说学习起来更加容易,也是比较简单的编程语言,被称为胶水语言,适合零基础以及初学者学习,Python目前市场上情况来说,需求量是非常大的,薪资待遇非常高,可以从事的工作岗位也是比较多,比如说:人工智能、数据分析、科学运算、web开发、爬虫、游戏开发等。 他是这样规划Python学习路线的 Python学习路线一:Python基础 必学知识:【Linux基础】【Python基础语法】【Python字符串】【文件操作】【异常处理】【Python面向对象】【项目实战】 路线讲解:该路线循序渐进,科学合理,帮助学习者建立正确的编程思想,具备基本的编程能力; Python学习路线二:Python高级编程 必学知识:【Python平台迁移Linux】【Python常用第三方库】【Python高级语法】【Python正则表达式】【网路编程】【系统编程】【数据结构与算法】【项目实战】 路线讲解

Keras `ImageDataGenerator` image and mask augments differently

允我心安 提交于 2021-01-02 08:10:12
问题 I'm training a semantic segmentation model using Keras with TensorFlow backend. I adopted ImageDataGenerator to do the image augmentation, including rotation, flip and shift. By following the documentation, I created a dictionary maskgen_args and used it as arguments to instantiate two ImageDataGenerator instances. maskgen_args = dict( rotation_range=90, validation_split=VALIDATION_SPLIT ) image_datagen = ImageDataGenerator(**maskgen_args) mask_datagen = ImageDataGenerator(**maskgen_args) The

How to add dimension to a tensor using Tensorflow

倖福魔咒の 提交于 2021-01-02 07:44:32
问题 I have method reformat in which using numpy I convert a label(256,) to label(256,2) shape. Now I want to do same operation on a Tensor with shape (256,) My code looks like this (num_labels=2) :-- def reformat(dataset, labels): dataset = dataset.reshape((-1, image_size, image_size,num_channels)).astype(np.float32) labels = (np.arange(num_labels)==labels[:,None]).astype(np.float32) return dataset, labels 回答1: You can use tf.expand_dims() to add a new dimension. In [1]: import tensorflow as tf x

How to add dimension to a tensor using Tensorflow

别来无恙 提交于 2021-01-02 07:44:22
问题 I have method reformat in which using numpy I convert a label(256,) to label(256,2) shape. Now I want to do same operation on a Tensor with shape (256,) My code looks like this (num_labels=2) :-- def reformat(dataset, labels): dataset = dataset.reshape((-1, image_size, image_size,num_channels)).astype(np.float32) labels = (np.arange(num_labels)==labels[:,None]).astype(np.float32) return dataset, labels 回答1: You can use tf.expand_dims() to add a new dimension. In [1]: import tensorflow as tf x

Custom loss function involving gradients in Keras/Tensorflow

。_饼干妹妹 提交于 2021-01-02 06:36:25
问题 I've seen that this question has been asked a few times before, but without any resolution. My problem is simple: I would like to implement a loss function which computes the MSE between the gradient of the prediction and the truth value (eventually moving on to much more complicated loss functions). I define the following two functions: def my_loss(y_true, y_pred, x): dydx = K.gradients(y_pred, x) return K.mean(K.square(dydx - y_true), axis=-1) def my_loss_function(x): def gradLoss(y_true, y

Custom loss function involving gradients in Keras/Tensorflow

对着背影说爱祢 提交于 2021-01-02 06:35:37
问题 I've seen that this question has been asked a few times before, but without any resolution. My problem is simple: I would like to implement a loss function which computes the MSE between the gradient of the prediction and the truth value (eventually moving on to much more complicated loss functions). I define the following two functions: def my_loss(y_true, y_pred, x): dydx = K.gradients(y_pred, x) return K.mean(K.square(dydx - y_true), axis=-1) def my_loss_function(x): def gradLoss(y_true, y

tensorflow gradient - getting all nan values

十年热恋 提交于 2021-01-02 06:14:15
问题 I am using python 3 with anaconda, and tensorflow 1.12 with eager eval. I am using it to create a triplet loss function for a siamese network, and need to calculate distance between different data samples. I created a function in order to create the distance calculation, but no matter what I do, when I try to calculate it's gradient with respect to the networks output, It keeps giving me all nan gradient. This is the code: def matrix_row_wise_norm(matrix): import tensorflow as tf tensor = tf

tensorflow gradient - getting all nan values

一曲冷凌霜 提交于 2021-01-02 06:13:08
问题 I am using python 3 with anaconda, and tensorflow 1.12 with eager eval. I am using it to create a triplet loss function for a siamese network, and need to calculate distance between different data samples. I created a function in order to create the distance calculation, but no matter what I do, when I try to calculate it's gradient with respect to the networks output, It keeps giving me all nan gradient. This is the code: def matrix_row_wise_norm(matrix): import tensorflow as tf tensor = tf

How to fix ' module 'keras.backend.tensorflow_backend' has no attribute '_is_tf_1''

自古美人都是妖i 提交于 2021-01-02 05:37:23
问题 While training the yolov3 framework, there's always this module error I have tried reinstalling keras and tensorflow, and the version of keras is 2.3.0 and the version of tensorflow is 1.14.0. Traceback (most recent call last): File "train.py", line 6, in <module> import keras.backend as K File "F:\Anacoda\lib\site-packages\keras\__init__.py", line 3, in <module> from . import utils File "F:\Anacoda\lib\site-packages\keras\utils\__init__.py", line 27, in <module> from .multi_gpu_utils import