Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Add tf.signal.frame() op. #1713

Merged
merged 8 commits into from
May 4, 2019
Merged

Conversation

Lewuathe
Copy link
Contributor

@Lewuathe Lewuathe commented Apr 29, 2019

Add frame op as provided in TensorFlow core. It's also needed to implement stft, istft ops to make slices of the sample.

See: tensorflow/tfjs#1362


This change is Reviewable

Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 approvals obtained (waiting on @Lewuathe)


src/ops/signal_ops.ts, line 72 at r1 (raw file):

 * @doc {heading: 'Operations', subheading: 'Signal', namespace: 'signal'}
 */
function frame_(input: Tensor1D, frameLength: number,

s/input/signal


src/ops/signal_ops.ts, line 73 at r1 (raw file):

 */
function frame_(input: Tensor1D, frameLength: number,
  frameStep: number): Tensor {

checking that you're using vscode and our autoformatter :)


src/ops/signal_ops.ts, line 73 at r1 (raw file):

 */
function frame_(input: Tensor1D, frameLength: number,
  frameStep: number): Tensor {

can you add padEnd, padValue, and axis?


src/ops/signal_ops.ts, line 85 at r1 (raw file):

  }

  return concat(output).as2D(output.length, frameLength);

output.concat


src/ops/signal_ops_test.ts, line 89 at r1 (raw file):

  it('3 length frames with step 5', () => {
    const input = tf.tensor1d([1, 2, 3, 4, 5]);
    const output = tf.frame(input, 3, 5);

this should be tf.signal.frame

the export here needs to be changed to export * as signal:

https://github.com/tensorflow/tfjs-core/blob/master/src/ops/ops.ts#L47

Copy link
Contributor Author

@Lewuathe Lewuathe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 approvals obtained (waiting on @Lewuathe and @nsthorat)


src/ops/signal_ops.ts, line 73 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

can you add padEnd, padValue, and axis?

Okay, I'll try.


src/ops/signal_ops.ts, line 85 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

output.concat

Actually, the output is not tensor. As it's just an array of tensor, we can not call ops directly.


src/ops/signal_ops_test.ts, line 89 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

this should be tf.signal.frame

the export here needs to be changed to export * as signal:

https://github.com/tensorflow/tfjs-core/blob/master/src/ops/ops.ts#L47

Will do.

Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r2.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @Lewuathe)


src/ops/signal_ops.ts, line 64 at r2 (raw file):

 *
 * ```js
 * tf.frame([1, 2, 3], 2, 1).print();

we just added a new CI that runs the snippets and checks for errors, this is failing now because you need to do tf.signal


src/ops/signal_ops.ts, line 66 at r2 (raw file):

 * tf.frame([1, 2, 3], 2, 1).print();
 * ```
 * @param input The input tensor to be expanded

s/input/signal

@nsthorat
Copy link
Contributor

Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @Lewuathe)


src/ops/signal_ops_test.ts, line 105 at r2 (raw file):

    const output = tf.signal.frame(input, 6, 0);
    expect(output.shape).toEqual([0, 6]);
    expectArraysClose(output, []);

FYI Apologies for this but once this PR is in you will have to do .data(): #1716

@Lewuathe
Copy link
Contributor Author

Lewuathe commented May 3, 2019

See this for failures: https://pantheon.corp.google.com/cloud-build/builds/ecf44c74-fa85-4c83-ae90-7f42c9d0c603?project=learnjs-174218

Thanks but unfortunately I do not have permission to look into that. But anyway, I guess the problem is fixed.

@nsthorat
Copy link
Contributor

nsthorat commented May 3, 2019

Ah apologies that's the internal version of the link, you can see the failure by clicking details:

image

@nsthorat
Copy link
Contributor

nsthorat commented May 3, 2019

Ah looks like we may have a bug, I think this will fix it: #1737

@nsthorat nsthorat changed the title Add frame op Add tf.signal.frame() op. May 4, 2019
@nsthorat nsthorat merged commit 7332dc5 into tensorflow:master May 4, 2019
@nsthorat
Copy link
Contributor

nsthorat commented May 4, 2019

Thanks for the awesome PR as always @Lewuathe :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants