Skip to content

Commit f7144ac

Browse files
committed
fix upgrade tensorflow
1 parent cc818b6 commit f7144ac

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/convolutional.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
445445
lo = float(lo) * freq_scale
446446
hi = float(hi) * freq_scale
447447
nyquist = audio_tic_rate/2
448-
nfreqs = x.get_shape().as_list()[2]
448+
nfreqs = x.shape[2]
449449
x = Slice([0, 0, round(nfreqs * lo / nyquist), 0],
450450
[-1, -1, round(nfreqs * (hi - lo) / nyquist), -1])(x)
451451
hidden_layers.append(x)
@@ -454,7 +454,7 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
454454
x = MelCepstrum(window_tics, stride_tics, audio_tic_rate,
455455
int(filterbank_nchannels), int(dct_ncoefficients))(x)
456456
hidden_layers.append(x)
457-
x_shape = x.get_shape().as_list()
457+
x_shape = x.shape
458458

459459
receptive_field = [1,1]
460460
sum_of_strides = [0,0]
@@ -478,8 +478,8 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
478478
sum_of_strides[0] += strides[0] - 1
479479
sum_of_strides[1] += strides[1] - 1
480480
if use_residual and iconv%2==0 and iconv>1:
481-
bypass_shape = bypass.get_shape().as_list()
482-
conv_shape = conv.get_shape().as_list()
481+
bypass_shape = bypass.shape
482+
conv_shape = conv.shape
483483
if bypass_shape[3]==conv_shape[3]:
484484
hoffset = (bypass_shape[1] - conv_shape[1]) // 2
485485
woffset = (bypass_shape[2] - conv_shape[2]) // 2
@@ -491,7 +491,7 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
491491
x = ReLU()(conv)
492492
if normalize_after:
493493
x = BatchNormalization()(x)
494-
x_shape = x.get_shape().as_list()
494+
x_shape = x.shape
495495
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size[0] + 1) / strides[0])
496496
iconv += 1
497497
dilation_rate = dilation(iconv+1, dilate_time, dilate_freq)
@@ -510,8 +510,8 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
510510
receptive_field[0] += (dilated_kernel_size - 1) * 2**sum_of_strides[0]
511511
sum_of_strides[0] += strides[0] - 1
512512
if use_residual and iconv%2==0 and iconv>1:
513-
bypass_shape = bypass.get_shape().as_list()
514-
conv_shape = conv.get_shape().as_list()
513+
bypass_shape = bypass.shape
514+
conv_shape = conv.shape
515515
if bypass_shape[2]==conv_shape[2] and bypass_shape[3]==conv_shape[3]:
516516
offset = (bypass_shape[1] - conv_shape[1]) // 2
517517
conv = Add()([conv, Slice([0,offset,0,0],[-1,conv_shape[1],-1,-1])(bypass)])
@@ -521,7 +521,7 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
521521
x = ReLU()(conv)
522522
if normalize_after:
523523
x = BatchNormalization()(x)
524-
x_shape = x.get_shape().as_list()
524+
x_shape = x.shape
525525
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size + 1) / strides[0])
526526
iconv += 1
527527
dilation_rate = dilation(iconv+1, dilate_time, dilate_freq)
@@ -539,7 +539,7 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
539539

540540
if pool_kind:
541541
x = pool_kind(pool_size=pool_size, strides=pool_size)(x)
542-
x_shape = x.get_shape().as_list()
542+
x_shape = x.shape
543543
noutput_tics = math.floor(noutput_tics / pool_size[0])
544544

545545
# final dense layers (or actually, pan-freq pan-time 2D convs)
@@ -550,7 +550,7 @@ def create_model(model_settings, model_parameters, io=sys.stdout):
550550
x = Dropout(dropout)(x)
551551
x = Conv2D(nunits, (noutput_tics if idense==0 else 1, x_shape[2]))(x)
552552
hidden_layers.append(conv)
553-
x_shape = x.get_shape().as_list()
553+
x_shape = x.shape
554554

555555
final = Reshape((-1,model_settings['nlabels']))(x)
556556

src/convolutional1.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def Identity(x): return lambda x: x
460460
lo = float(lo) * freq_scale
461461
hi = float(hi) * freq_scale
462462
nyquist = audio_tic_rate/2
463-
nfreqs = x.get_shape().as_list()[2]
463+
nfreqs = x.shape[2]
464464
x = Slice([0, 0, round(nfreqs * lo / nyquist), 0],
465465
[-1, -1, round(nfreqs * (hi - lo) / nyquist), -1])(x)
466466
hidden_layers.append(x)
@@ -469,7 +469,7 @@ def Identity(x): return lambda x: x
469469
x = MelCepstrum(window_tics, stride_tics, audio_tic_rate,
470470
int(filterbank_nchannels), int(dct_ncoefficients))(x)
471471
hidden_layers.append(x)
472-
x_shape = x.get_shape().as_list()
472+
x_shape = x.shape
473473

474474
receptive_field = [1,1]
475475
sum_of_strides = [0,0]
@@ -493,8 +493,8 @@ def Identity(x): return lambda x: x
493493
sum_of_strides[0] += strides[0] - 1
494494
sum_of_strides[1] += strides[1] - 1
495495
if use_residual and iconv%2==0 and iconv>1:
496-
bypass_shape = bypass.get_shape().as_list()
497-
conv_shape = conv.get_shape().as_list()
496+
bypass_shape = bypass.shape
497+
conv_shape = conv.shape
498498
if bypass_shape[3]==conv_shape[3]:
499499
hoffset = (bypass_shape[1] - conv_shape[1]) // 2
500500
woffset = (bypass_shape[2] - conv_shape[2]) // 2
@@ -507,7 +507,7 @@ def Identity(x): return lambda x: x
507507
if normalize_after:
508508
relu = BatchNormalization()(relu)
509509
x = dropout_kind(dropout_rate)(relu)
510-
x_shape = x.get_shape().as_list()
510+
x_shape = x.shape
511511
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size[0] + 1) / strides[0])
512512
iconv += 1
513513
dilation_rate = dilation(iconv+1, dilate_time, dilate_freq)
@@ -526,8 +526,8 @@ def Identity(x): return lambda x: x
526526
receptive_field[0] += (dilated_kernel_size - 1) * 2**sum_of_strides[0]
527527
sum_of_strides[0] += strides[0] - 1
528528
if use_residual and iconv%2==0 and iconv>1:
529-
bypass_shape = bypass.get_shape().as_list()
530-
conv_shape = conv.get_shape().as_list()
529+
bypass_shape = bypass.shape
530+
conv_shape = conv.shape
531531
if bypass_shape[2]==conv_shape[2] and bypass_shape[3]==conv_shape[3]:
532532
offset = (bypass_shape[1] - conv_shape[1]) // 2
533533
conv = Add()([conv, Slice([0,offset,0,0],[-1,conv_shape[1],-1,-1])(bypass)])
@@ -538,7 +538,7 @@ def Identity(x): return lambda x: x
538538
if normalize_after:
539539
relu = BatchNormalization()(relu)
540540
x = dropout_kind(dropout_rate)(relu)
541-
x_shape = x.get_shape().as_list()
541+
x_shape = x.shape
542542
noutput_tics = math.ceil((noutput_tics - dilated_kernel_size + 1) / strides[0])
543543
iconv += 1
544544
dilation_rate = dilation(iconv+1, dilate_time, dilate_freq)
@@ -553,7 +553,7 @@ def Identity(x): return lambda x: x
553553

554554
if pool_kind:
555555
x = pool_kind(pool_size=pool_size, strides=pool_size)(x)
556-
x_shape = x.get_shape().as_list()
556+
x_shape = x.shape
557557
noutput_tics = math.floor(noutput_tics / pool_size[0])
558558

559559
# final dense layers (or actually, pan-freq pan-time 2D convs)
@@ -562,7 +562,7 @@ def Identity(x): return lambda x: x
562562
relu = ReLU()(x)
563563
x = dropout_kind(dropout_rate)(relu)
564564
x = Conv2D(nunits, (noutput_tics if idense==0 else 1, x_shape[2]))(x)
565-
x_shape = x.get_shape().as_list()
565+
x_shape = x.shape
566566

567567
final = Reshape((-1,model_settings['nlabels']))(x)
568568

src/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def network(PARAMS, inputs):
304304
i = PARAMS['data_format'] == 'channels_first'
305305
x = layers.Conv3D(
306306
filters=PARAMS['num_labels'],
307-
kernel_size=[PARAMS["noutput_tics"], *x.get_shape().as_list()[(i+2):(i+4)]],
307+
kernel_size=[PARAMS["noutput_tics"], *x.shape[(i+2):(i+4)]],
308308
use_bias=PARAMS['use_bias'],
309309
kernel_initializer=PARAMS['initializer'],
310310
kernel_regularizer=regularizer(PARAMS),

0 commit comments

Comments
 (0)