deep-learning

How to get layer weight while training?

只愿长相守 提交于 2021-02-10 14:35:23
问题 I have a model and I would like to get the weight matrix of a specific layer to use it while defining custom loss function. Is there any way to get a weight of specific layer, inside the model? P.S. I am currently working with tensorflow 2, and keras functional API. I tested How do I get the weights of a layer in Keras? approach, but it did not work. P.P.S. By using the above described approach, I get the following error: AttributeError Traceback (most recent call last) <ipython-input-26

Shape error when passed custom LSTM

六月ゝ 毕业季﹏ 提交于 2021-02-10 14:21:01
问题 I have been trying to custom a LSTM layer for further improvement. But an error which seems like normal raised at pooling layer after my custom LSTM. My environment is: win 10 keras 2.2.0 python 3.6 Traceback (most recent call last): File "E:/PycharmProjects/dialogResearch/dialog/classifier.py", line 60, in model = build_model(word_dict, args.max_len, args.max_sents, args.embedding_dim) File "E:\PycharmProjects\dialogResearch\dialog\model\keras_himodel.py", line 177, in build_model l_dense =

How can we use lbfgs_minimize in TensorFlow 2.0

馋奶兔 提交于 2021-02-10 12:00:33
问题 I have been unable to reproduce this example from tensorflow having tensorflow 2.0 installed. This is the original snippet: # A high-dimensional quadratic bowl. ndims = 60 minimum = np.ones([ndims], dtype='float64') scales = np.arange(ndims, dtype='float64') + 1.0 # The objective function and the gradient. def quadratic(x): value = tf.reduce_sum(scales * (x - minimum) ** 2) return value, tf.gradients(value, x)[0] start = np.arange(ndims, 0, -1, dtype='float64') optim_results = tfp.optimizer

How can we use lbfgs_minimize in TensorFlow 2.0

余生长醉 提交于 2021-02-10 11:58:16
问题 I have been unable to reproduce this example from tensorflow having tensorflow 2.0 installed. This is the original snippet: # A high-dimensional quadratic bowl. ndims = 60 minimum = np.ones([ndims], dtype='float64') scales = np.arange(ndims, dtype='float64') + 1.0 # The objective function and the gradient. def quadratic(x): value = tf.reduce_sum(scales * (x - minimum) ** 2) return value, tf.gradients(value, x)[0] start = np.arange(ndims, 0, -1, dtype='float64') optim_results = tfp.optimizer

How to get add aditional transform to get_transform in fastai?

谁说我不能喝 提交于 2021-02-10 05:42:07
问题 I would like to add aditional augmenmentation this way: additional_aug=[zoom_crop(scale=(0.75,1.25), do_rand=False), brightness(), contrast() ] tfms = get_transforms(do_flip=True,flip_vert=True,max_lighting=0.2, xtra_tfms=additional_aug) data = (ImageList.from_df(df=df,path='./',cols='path') .split_by_rand_pct(0.2) .label_from_df(cols='diagnosis',label_cls=FloatList) .transform(tfms,size=sz,resize_method=ResizeMethod.SQUISH,padding_mode='zeros') .databunch(bs=bs,num_workers=4) .normalize

cannot reshape array of size 1665179 into shape (512,512,3,3)

断了今生、忘了曾经 提交于 2021-02-10 05:33:24
问题 The script used to do detection. Weight file was yolov4 coco pre-trained model and that can be found over here.(https://drive.google.com/file/d/1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT/view) import time from absl import app, flags, logging from absl.flags import FLAGS import core.utils as utils from core.yolov4 import YOLOv4, YOLOv3, YOLOv3_tiny, decode from PIL import Image from core.config import cfg import cv2 import numpy as np import tensorflow as tf flags.DEFINE_string('framework', 'tf', '(tf,

How to use Reshape keras layer with two None dimension?

喜你入骨 提交于 2021-02-09 09:35:41
问题 I have a keras 3D/2D model. In this model a 3D layer has a shape of [None, None, 4, 32]. I want to reshape this into [None, None, 128]. However, if I simply do the following: reshaped_layer = Reshape((-1, 128))(my_layer) my_layer has a shape of [None, 128] and therefore I cannot apply afterwards any 2D convolution, like: conv_x = Conv2D(16, (1,1))(reshaped_layer) I've tried to use tf.shape(my_layer) and tf.reshape, but I have not been able to compile the model since tf.reshape is not a Keras

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

女生的网名这么多〃 提交于 2021-02-09 05:58:44
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

穿精又带淫゛_ 提交于 2021-02-09 05:58:13
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop

ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: [None, 2584]

混江龙づ霸主 提交于 2021-02-09 05:55:40
问题 I'm working in a project that isolate vocal parts from an audio. I'm using the DSD100 dataset, but for doing tests I'm using the DSD100subset dataset from I only use the mixtures and the vocals. I'm basing this work on this article First I process the audios to extract a spectrogram and put it on a list, with all the audios forming four lists (trainMixed, trainVocals, testMixed, testVocals). Like this: def to_spec(wav, n_fft=1024, hop_length=256): return librosa.stft(wav, n_fft=n_fft, hop